Php-Arrays function-array_merge-merge one or more Arrays

Source: Internet
Author: User

Array_merge () combines one or more Arrays

[Function]
This function combines the units of one or more arrays. The values of an array are appended to the values of the previous array.
Returns an array of results. If the input array contains the same string key name, these values will be overwritten by the previous
Value. However, if the array has the same numeric key name, the last value will not overwrite the original value.
Is appended to the backend. If only one array is assigned and the array is a digital index, the key name is continuously indexed.
Scope of use]
Php4, php5.
[Use]
Array array_merge (array array1 [, array array2 [, array...])
Arrayn/required/array to be used for merging
[Example]
[Php]
<Pre name = "code" class = "php"> <? Php
$ Arr1 = array ("color" => array ("favorite" => "red"), 5 );
$ Arr2 = array (10, "color" => array ("favorite" => "green", "blue "));
Var_dump (array_merge ($ arr1 ));
/*
Array (2 ){
["Color"] =>
Array (1 ){
["Favorite"] =>
String (3) "red"
}
[0] =>
Int (5)
}
*/

 


Taken from zuodefeng's note

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.