From http://www.w3schools.com (Copyright Refsnes Data)

PHP array_shift() Function


PHP Array Reference Complete PHP Array Reference

Definition and Usage

The array_shift() function removes the first element from an array, and returns the value of the removed element.

Syntax

array_shift(array)

Parameter Description
array Required. Specifies an array


Tips and Notes

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


Example 1

<?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 ) 


Example 2

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 )


PHP Array Reference Complete PHP Array Reference

From http://www.w3schools.com (Copyright Refsnes Data)