从PHP多维数组删除重复值 [英] PHP remove duplicate values from multidimensional array
本文介绍了从PHP多维数组删除重复值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以使用 array_unique()
为删除重复的php.Is从单一的多维数组的加入,因此可能的多维数组使用?它不是为我工作!
We can use array_unique()
for remove duplicate entry from a single multidimensional array in php.Is it possible to use with multidimensional array? It is not working for me!
下面是该数组样子
Array (
[0] => Array ( [0] => 1001 [1] => john [2] => example )
[1] => Array ( [0] => 1002 [1] => test [2] => dreamz )
[2] => Array ( [0] => 1001 [1] => john [2] => example )
[3] => Array ( [0] => 1001 [1] => example [2] => john )
[4] => Array ( [0] => 1001 [1] => john [2] => example )
)
任何人都可以请帮我...
Anybody can please help me...
推荐答案
array_unique 页面上的用户评论做一些线索这一点。你很可能会发现在这些意见的一些隐藏的宝石 - 它是一个非常方便的文档。
The user comments on the array_unique page do shed some light on this. You will most likely find some hidden gems in those comments - its a very handy documentation.
刚刚经历揭示了以下从一个多维数组中删除重复快速的浏览器:
Just a quick browser through revealed the following to remove duplicates from a multi dimensional array:
<?php
function super_unique($array)
{
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
foreach ($result as $key => $value)
{
if ( is_array($value) )
{
$result[$key] = super_unique($value);
}
}
return $result;
}
?>
这篇关于从PHP多维数组删除重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文