Php-Arrays function-array_unshift-insert one or more cells at the beginning of the array _ PHP Tutorial

Source: Internet
Author: User
Php-Arrays function-array_unshift-insert one or more units at the beginning of the array. Array_unshitf () inserts one or more units at the beginning of the array [function] This function inserts incoming units into the beginning of the specified array. Note that the units are inserted as a whole, therefore, input array_unshitf () to insert one or more units at the beginning of the array.

[Function]
This function inserts the incoming unit into the beginning of the specified array.
Note that the unit is inserted as a whole, so the incoming unit will be in the same order.
All numeric keys will be changed to count again from scratch, and all text keys will remain unchanged.
Returns the number of new elements in the array.
Scope of use]
Php4, php5.
[Use]
Int array_unshift (array & array, mixed var [, mixed...])
& Array/required/the original array to be inserted
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"
}
*/


Taken from zuodefeng's note

Http://www.bkjia.com/PHPjc/478193.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478193.htmlTechArticlearray_unshitf () inserts one or more units at the beginning of an array [function] This function inserts incoming units into the beginning of a specified array. Note that units are inserted as a whole, so Upload...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.