HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_shift

Description

The array_shift of Array for PHP shift an element off the beginning of array.

Syntax

array_shift(array &$array): mixed

Parameters

array

The input array.

Return

Returns the shifted value, or null if array is empty or is not an array.

Examples

1 · array

<?

$array = array("apple", "banana", "coconut");

array_shift($array);

print_r($array);
Array
(
    [0] => banana
    [1] => coconut
)

2 · return · first

<?

$array = array("apple", "banana", "coconut");

$return = array_shift($array);

print_r($return);
apple

3 · return · empty

<?

$array = array();

$return = array_shift($array);

var_export($return);
NULL