PHP array_shift function

Last Updated: February 15, 2022

array_shift — Shift an element off the beginning of the array

Syntax

 array_shift(array &$array): mixed

Supports (PHP 4 , PHP 5, PHP 7, PHP 8)

Parameters

Parameter Description
array target array

Return Value

returns the shifted array

Example

$arr1 = array("one","two","three" );
$result = array_shift($arr1);
print_r($arr1);

Output

Array ( [0] => two [1] => three ) 
Test