php-arrays function-array_merge_recursive-Merge one or more arrays recursively _php tutorial

Source: Internet
Author: User
Array_merge_recursive () to merge one or more arrays recursively

function
The function merges the cells of one or more arrays, and the values in an array are appended to the previous array.
Returns an array as the result. If the input array has the same string key name, the values are merged into a
Array, this will recursively go down, so if a value itself is an array, then the function will merge it according to the corresponding entry
to another array. However, if the array has exactly the same array key name, the latter value will not overwrite the original value, and
is attached to the back.
"Scope of Use"
php4>4.0.1, PHP5.
Use
Array array_merge_recursive (array array1[,array ...])
arrayn/required/upcoming arrays for merging
Example
[PHP]
$arr 1 = Array ("Color" =>array ("favorite" = "Red"), 5);
$arr 2 = Array ("Color" =>array ("favorite" = "green", "Blue"));
Var_dump (Array_merge_recursive ($arr 1, $arr 2));
/*
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)
}
*/


Excerpts from Zuodefeng's notes

http://www.bkjia.com/PHPjc/478215.html www.bkjia.com true http://www.bkjia.com/PHPjc/478215.html techarticle array_merge_recursive () recursively merges one or more array "functions" the function merges the cells of one or more arrays, and the value in one is appended to 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.