如何从 PHP 中的多维数组中删除重复值
如何在 PHP 中删除多维数组中的重复值?
How can I remove duplicate values from a multi-dimensional array in PHP?
示例数组:
Array
(
[0] => Array
(
[0] => abc
[1] => def
)
[1] => Array
(
[0] => ghi
[1] => jkl
)
[2] => Array
(
[0] => mno
[1] => pql
)
[3] => Array
(
[0] => abc
[1] => def
)
[4] => Array
(
[0] => ghi
[1] => jkl
)
[5] => Array
(
[0] => mno
[1] => pql
)
)
推荐答案
这是另一种方式.不保存中间变量.
Here is another way. No intermediate variables are saved.
我们使用它对来自各种重叠查询的结果进行重复数据删除.
We used this to de-duplicate results from a variety of overlapping queries.
$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
相关文章