摘要:
下文讲述php中array_merge_recursive函数的功能讲解,如下所示;
array_merge_recursive函数功能说明:
将两个或多个数组合并为一个新数组,
当遇到数组中键相同时,则会将相同键形成一个新的数组(新数组中包含相同键的值)
放入数组中
array_merge_recursive语法:
array_merge_recursive(array1,array2,array3...)
--------参数说明------
array1:必填参数,待合并数组1
array2:可选参数,待合并数组2
array3:可选参数,待合并数组3
--------返回值说明-----
返回由数组1和数组2和数组3组成一个新数组
------注意事项----
当合并数组中存在相同键时,会将相同键值组成一个新数组
例:
php数组之array_merge_recursive函数示例分享
echo "maomao365.com php 数组合并的示例分享\n";
$a1=array("a"=>"maomao","b"=>"linux");
$a2=array("c"=>"other","b"=>"testInfomation");
print_r(array_merge_recursive($a1,$a2));
?>
//输出
maomao365.com php 数组合并的示例分享
Array
(
[a] => maomao
[b] => Array
(
[0] => linux
[1] => testInfomation
)
[c] => other
)