結論
array_merge: 合併時,重複的Key會被覆蓋
加號 +: 合併時,重複的Key會被沿用
陣列 Array 合併
$arr1 = ['one' => '1']; $arr2 = ['one' => 'a', 'two' => 'b']; array_merge($arr1, $arr2); // [ "one" => "a", "two" => "b"] $arr1 + $arr2; // [ "one" => "1", "two" => "b"]
結論
array_merge: 合併時,重複的Key會被覆蓋
加號 +: 合併時,重複的Key會被沿用
陣列 Array 合併
$arr1 = ['one' => '1']; $arr2 = ['one' => 'a', 'two' => 'b']; array_merge($arr1, $arr2); // [ "one" => "a", "two" => "b"] $arr1 + $arr2; // [ "one" => "1", "two" => "b"]