Php-Arrays function-array_merge_recursive-recursively merge one or more Arrays _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
The php-Arrays function-array_merge_recursive-recursively merges one or more Arrays. Array_merge_recursive () recursively merges 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. array_merge_recursive () recursively merge 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 has the same string key name, these values will be merged into
In the array, this will be recursive, so if a value itself is an array, the function will merge it according to the corresponding entries
Is another array. However, if the array has the same key name, the last value will not overwrite the original value.
Is appended to the backend.
Scope of use]
Php4> 4.0.1, php5.
[Use]
Array array_merge_recursive (array array1 [, array...])
Arrayn/required/array to be used for merging
[Example]
[Php]
$ Arr1 = array ("color" => array ("favorite" => "red"), 5 );
$ Arr2 = array (10, "color" => array ("favorite" => "green", "blue "));
Var_dump (array_merge_recursive ($ arr1, $ arr2 ));
/*
Array (3 ){
["Color"] =>
Array (2 ){
["Favorite"] =>
Array (2 ){
[0] =>
String (3) "red"
[1] =>
String (5) "green"
}
[0] =>
String (4) "blue"
}
[0] =>
Int (5)
[1] =>
Int (10)
}
*/


Taken from zuodefeng's note

Http://www.bkjia.com/PHPjc/478215.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478215.htmlTechArticlearray_merge_recursive () recursively merges one or more arrays [function] This function combines the units of one or more arrays, the values of an array are appended to the back of the previous array...

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.