← All built-ins / array_shift()

array_shift()

array_shift(...$args): mixed

Parameters

NameTypeDescription
$aarrayarray (by reference)

Return value

The removed first element; the rest is re-indexed.

Example

$a = [1, 2, 3];
$first = array_shift($a);
echo $first, " ", implode(",", $a);
1 2,3

See also

array_unshift()array_pop()