Copyright © tutorialspoint.com
| array_shift ( $array ); |
This function shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero while literal keys won't be touched.
| Parameter | Description |
|---|---|
| array | Required. Specifies an array. |
Returns first element of the array and if array is empty (or is not an array), NULL will be returned.
Try out following example:
<?php
$array=array("a"=>"banana","b"=>"apple","c"=>"orange");
print_r(array_shift($array));
print_r("<br />");
print_r(array_shift($array));
?>
|
This will produce following result:
banana apple |
Copyright © tutorialspoint.com