2014-01-05 73 views

回答

5
$final_array = array_unique(array_merge($array_1, $array_2)); 

希望有幫助!

+0

感謝您接受 - 快樂編碼 –

6

使用

$final_array = array_unique(array_merge($array_1, $array_2)); 

手冊從array_merge()

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

在你的情況重複值array_merge後追加,所以你需要合併,刪除重複值後調用array_unique

+0

我幾乎要發佈這個:-)你們是搖滾樂! –

相關問題