Home >Backend Development >PHP Tutorial >php-Arrays function-array_shift-remove a unit at the beginning of the array_PHP tutorial

php-Arrays function-array_shift-remove a unit at the beginning of the array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:231089browse

array_shift() removes a cell at the beginning of the array

【Function】
This function will pop up and return the first cell of the array, and then reduce the length of the array by one
            All numeric key names will be changed to count from zero
If array is empty or not an array, null will be returned
【Scope of use】
​​​​​ php4, php5.
【Use】
            mixed array_shift( array &array )
            array/required/upcoming function processing array
【Example】
[php]
$array = array('orange','banana','apple');
var_dump($array);
var_dump(array_shift($array));
var_dump($array);
/*
array(3) {
[0]=>
string(6) "orange"
[1]=>
string(6) "banana"
[2]=>
string(5) "apple"
}
string(6) "orange"
array(2) {
[0]=>
string(6) "banana"
[1]=>
string(5) "apple"
}
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478191.htmlTechArticlearray_shift() removes a unit at the beginning of the array [Function] This function will pop up and return the beginning of the array array unit, then reduce the length of the array by one and all numeric key names will be changed from...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn