php-arrays function-array_unshift-inserting one or more cells at the beginning of an array _php tutorial

Source: Internet
Author: User
ARRAY_UNSHITF () inserts one or more cells at the beginning of the array

function
The function inserts the incoming cell at the beginning of the specified array
Note that the unit is inserted as a whole, so incoming cells will remain in the same order
All numeric key names are modified to count back from zero, and all text key names remain unchanged
Finally returns the number of new cells in the array
"Scope of Use"
PhP4, PHP5.
Use
int Array_unshift (array &array,mixed var[,mixed ...])
&array/Required/Imminent insert operation original array
var/required/About to add value
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"
}
*/


Excerpts from Zuodefeng's notes

http://www.bkjia.com/PHPjc/478193.html www.bkjia.com true http://www.bkjia.com/PHPjc/478193.html techarticle ARRAY_UNSHITF () inserts one or more cell "functions" at the beginning of the array the function inserts the incoming cell into the beginning of the specified array. Note that the unit is inserted as a whole, so pass ...

  • 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.