php-Arrays function-array_merge_recursive-recursively merge one or more arrays_PHP tutorial

WBOY
Release: 2016-07-13 17:51:15
Original
1390 people have browsed it

array_merge_recursive() recursively merges one or more arrays

【Function】
This function combines the elements of one or more arrays. The values ​​in one array are appended to the previous array.
                                                        Return the array as the result. If the input arrays have the same string key name, the values ​​will be merged into one
​​​​​In an array, this will go down recursively, so if a value is itself an array, the function will merge it according to the corresponding entry
                           is another array. However, if the array details have the same array key name, the latter value will not overwrite the original value, and
is appended to the back.
【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)
}
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478215.htmlTechArticlearray_merge_recursive() Recursively merge one or more arrays [Function] This function merges the units of one or more arrays Combined, the values ​​in one array are appended to the previous array...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!