您好,我正在尝试合并两个数组,并且还想从最终数组中删除重复值。
这是我的数组 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
)
我想删除这些重复的条目,或者我可以在合并之前删除它们吗... 请帮助.. 谢谢!!!!!!!
最佳答案
array_unique(array_merge($array1,$array2), SORT_REGULAR);
关于PHP - 将两个数组合并为一个数组(也删除重复项),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13469803/