Home > Backend Development > PHP Tutorial > php-Arrays function-array_unshift-insert one or more cells at the beginning of the array_PHP tutorial

php-Arrays function-array_unshift-insert one or more cells at the beginning of the array_PHP tutorial

WBOY
Release: 2016-07-13 17:51:37
Original
1316 people have browsed it

array_unshitf() inserts one or more cells at the beginning of the array

【Function】
This function inserts the passed in unit to the beginning of the specified array
                                                              Note that the cells are inserted as a whole, so the incoming cells will maintain the same order
            All numerical key names will be modified to count again from zero, and all text key names will remain unchanged
                                                                    Finally, return the new number of cells in the array
【Scope of use】
​​​​​ php4, php5.
【Use】
int array_unshift( array &array,mixed var[,mixed...] )
& Array/Necessary/The original array of the operation of the operation
        var/required/value to be added
【Example】
[php]
$array=array("orange","banana");
var_dump(array_unshift($array,'apple','raspberry'));
var_dump($array);
/*
int(4)
array(4) {
[0]=>
string(5) "apple"
[1]=>
string(9) "raspberry"
[2]=>
string(6) "orange"
[3]=>
string(6) "banana"
}
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478193.htmlTechArticlearray_unshitf() Insert one or more units at the beginning of the array [Function] This function inserts the incoming unit Go to the beginning of the specified array. Note that the unit is inserted as a whole, so pass...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template