PHP array_shift() Function

The array_shift() function is used to remove the first element from an array, and returns the value of the removed element.

Note: If the keys are numeric, all elements will get new keys, starting from 0 and increases by 1.

ParameterDescription
arrayRequired. Specifies an array

Syntax

 array_shift(array) 

Example

$array = array(0=>"Cooper",1=>5,2=>"Samuel");
echo array_shift($array);
print_r($array);

Leave a Reply

Your email address will not be published. Required fields are marked *