刪除dups或創建沒有dups的新數組的最有效方法是什麼?有沒有內置的PHP函數可以保存這個手動刪除?PHP - 刪除對象數組中的重複項
[2013-05-27 22:35:55]: Array
(
[0] => stdClass Object
(
[type] => 1
[val] => 1111
)
[1] => stdClass Object
(
[type] => 1
[val] => 2222
)
[2] => stdClass Object
(
[type] => 1
[val] => 1111
)
[3] => stdClass Object
(
[type] => 1
[val] => 2222
)
)
非常感謝,盧克
看看這裏http://stackoverflow.com/questions/4507518/will-array-unique-work-also-with-array-of-objects – user4035
$ final = array(); foreach($合併爲$ current){ if(!in_array($ current,$ final)){ $ final [] = $ current; } } var_dump($ final); –
[**'array_unique' **](http://php.net/manual/en/function.array-unique.php)與使用**'SORT_REGULAR' **的對象數組一起工作。看到我的答案:http://stackoverflow.com/questions/4507518/will-array-unique-work-also-with-array-of-objects/18203564#18203564 –