php里面貌似这两种方法都可以合并数组,我就发现了一点,就是array_merge
是后面覆盖前面,而+
是前面覆盖后面,比如下面的代码
$a = array('a' => 1, 'b' => 2, 'c' => 3); $b = array('b' => 5, 'c' => 6, 'd' => 7); print_r(array_merge($a, $b)); print_r($a + $b);
就输出
Array( [a] => 1 [b] => 5 [c] => 6 [d] => 7)Array( [a] => 1 [b] => 2 [c] => 3 [d] => 7)
翻过高山走不出你
慕姐4208626