Things you might need to know about Php

Lately I am spending some time with tests on hackerrank to improve my algorithm skills. This post will list all the nitty gritty stuff I've came accross with.

1. Do not use array_slice when you have big arrays.

On top of the following implementation, array_slice will renumerate the numeric array indexes. Therefore it will be slower. Instead, you can use the following to shift the array:

function array_slice_faster(&array) {
    $item = reset($a);
    return $item;