如何使用相同的键附加两个关联数组

时间:2013-04-28 09:24:45

标签: php

I have two arrays with same key names and some times value may be same. I want to append these two arrays into one new array. I have added screen shot of these array. I found array_merge but I saw it overrides instead of append.  Is there any function in php to do this or I have write custome function.

我有两个具有相同键名的数组,有时值可能相同。我想将这两个数组附加到一个新数组中。我添加了这些阵列的屏幕截图。我找到了array_merge,但我看到它覆盖而不是追加。在php中是否有任何功能可以执行此操作,或者我已经编写了自定义功能。

1 个答案:

答案 0 :(得分:5)

尝试使用

array_merge_recursive($array1, $array2);