From http://www.w3schools.com (Copyright Refsnes Data)
The array_shift() function removes the first element from an array, and returns the value of the removed element.
array_shift(array) |
Parameter | Description |
---|---|
array | Required. Specifies an array |
Note: If the keys are numeric, all elements will get new keys, starting from 0 and increases by 1. (See example 2)
<?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); echo array_shift($a); print_r ($a); ?> |
The output of the code above will be:
Dog Array ( [b] => Cat [c] => Horse ) |
With numeric keys:
<?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse"); echo array_shift($a); print_r ($a); ?> |
The output of the code above will be:
Dog Array ( [0] => Cat [1] => Horse ) |
From http://www.w3schools.com (Copyright Refsnes Data)