php array_shift() function


  Translation results:

英[ʃɪft] 美[ʃɪft]

vt.& vi. change; shift gears; remove; get rid of

vt. Change clothes of..., change (clothes); sell , sell; [computer] displace (data)

vi. (car) shift gears; change clothes; muddle through; make a living for oneself

n. Move, transfer, convert; change, change, Transform, replace, replace, swap, make it easier, substitute;

Third person singular: shifts Plural: shifts Present participle: shifting Past tense: shifted Past participle: shifted

php array_shift() functionsyntax

Function: Delete the first element in the array and return the value of the deleted element.

Syntax: array_shift(array)

Parameters:

Parameter Description
arrayRequired. Specifies an array.

Description: Returns the value of the element removed from the array, or NULL if the array is empty.

php array_shift() functionexample

<?php
$a=array(0=>"西门",1=>"灭绝",2=>"无忌");
echo array_shift($a); //输出被删除的 数组元素的值
echo "<br>";
print_r ($a); //打印处理后的数组
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

西门
Array ( [0] => 灭绝 [1] => 无忌 )


<?php
$a=array(0=>"欧阳克",1=>"无忌",2=>"Peter_zhu");
echo array_shift($a); //输出被删除的 数组元素的值
echo "<br>";
print_r ($a); //打印处理后的数组
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

欧阳克
Array ( [0] => 无忌 [1] => Peter_zhu )

Home

Videos

Q&A