嗨我試圖合併兩個數組,也想從最終數組中刪除重複值。PHP - 將兩個數組合併成一個數組(也是刪除重複)
這是我的陣列1:
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
)
這是我的陣列2:
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
)
我使用array_merge
用於合併兩個陣列成一個陣列。它給輸出這樣
Array
(
[0] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
[1] => stdClass Object
(
[ID] => 749
[post_author] => 1
[post_date] => 2012-11-20 06:26:07
[post_date_gmt] => 2012-11-20 06:26:07
)
我想刪除這些重複的條目,或者我可以合併之前刪除這些... 普萊斯幫助.. 謝謝!!!!!!!
因爲你想合併$ array1 [0]和$ array2 [0]而不是$ array1和$ array2。嘗試在每個陣列的第一項上運行array_merge – Bgi
數組是動態的..所以它不會總是$ array1 [0]和$ array2 [0] – Ravi
有什麼我可以比較數組內的每個對象的ID? ?? – Ravi