What's the difference between array_merge and array + array?

后端 未结 9 1652
遥遥无期
遥遥无期 2020-11-29 21:26

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

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

and

$merged = $array1 +          


        
9条回答
  •  醉话见心
    2020-11-29 21:54

    array_merge() causes all numeric keys found in the input arrays to be reindexed in the resultant array. The union operator + does not cause a reindex.

提交回复
热议问题