こんにちは。2 つの配列を結合し、最終的な配列から重複する値を削除したいと考えています。
これが私の配列 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
)
両方の配列を1つの配列にマージするために使用しています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
)
これらの重複エントリを削除したいのですが、マージする前に削除できますか... 助けてください。ありがとうございます!!!!!!!
ベストアンサー1
array_unique(array_merge($array1,$array2), SORT_REGULAR);