来自官方示例
$array1 = array("color" => "red", 2, 4); $array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4); $result = array_merge($array1, $array2); print_r($result);
数组中有的标记了下标,有的没有标记下标(索引)
有下标的将会沿用下标,如果下标相同,则会覆盖
没有下标的,将会从0开始索引
值不会覆盖
结果
Array ( [color] => green [0] => 2 [1] => 4 [2] => a [3] => b [shape] => trapezoid [4] => 4 )
Leave a Reply