是的,array_merge()
函数可以处理多维数组。它会按照从左到右的顺序合并一个或多个数组,包括多维数组。当合并多维数组时,它会递归地将数组的每个元素合并在一起。
下面是一个例子:
"red", "shape" => "trapezoid", "prices" => array( "current" => 10, "previous" => 20 ) ); $array2 = array( "color" => "blue", "shape" => "rectangle", "prices" => array( "current" => 15, "previous" => 25 ) ); $result = array_merge($array1, $array2); print_r($result); ?>
输出结果:
Array ( [color] => blue [shape] => rectangle [prices] => Array ( [current] => 15 [previous] => 25 ) )
可以看到,array_merge()
函数成功地将两个多维数组合并为一个。