September 2001
Intermediate to advanced
768 pages
32h 45m
English
mixed array_shift(array array) Returns the first element of the array and removes the element from the array.
Returns:
First element of an array; NULL on failure or if the array is empty
Description:
This function pulls the first element off the array and returns it, while shortening the array by the first element and moving all other elements down by one.
Used with array_push(), this function can make an array act in FIFO (first-in-first-out) fashion.
Warning:
This function directly alters the array passed to it.
Version:
PHP 4
See also:
array_pop() array_push() array_unshift()
Example:
$arr1 = array("one", "two", "three", "four"); echo "First element was: ", array_shift($arr1), ... |
Read now
Unlock full access