array_merge 和 array + array 有什么区别?

array_merge 和 array + array 有什么区别?

问题描述:

一个相当简单的问题.有什么区别:

A fairly simple question. What's the difference between:

$merged = array_merge($array1, $array2);

$merged = $array1 + $array2;

?

区别在于:

+ 运算符采用两个数组的联合,而 array_merge 函数采用联合重复键被覆盖.

The + operator takes the union of the two arrays, whereas the array_merge function takes the union BUT the duplicate keys are overwritten.