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