How to Remove Array Element and Then Re-Index Array?
unset($foo[0]); // remove item at index 0
$foo2 = array_values($foo); // 'reindex' array
You better use array_shift()
. That will return the first element of the array, remove it from the array and re-index the array. All in one efficient method.
array_splice($array, 0, 1);
http://php.net/manual/en/function.array-splice.php