php 二维数组过滤相同的值
Array([0]=>Array([names]=>abc[staus]=>1)[1]=>Array([names]=>ddd[staus]=>1)[2]=>Array(...
Array
(
[0] => Array
(
[names] => abc
[staus] => 1
)
[1] => Array
(
[names] => ddd
[staus] => 1
)
[2] => Array
(
[names] => ddd
[staus] => 1
)
)
如何过滤相同的值
变成这样
Array
(
[0] => Array
(
[names] => abc
[staus] => 1
)
[1] => Array
(
[names] => ddd
[staus] => 1
)
) 展开
(
[0] => Array
(
[names] => abc
[staus] => 1
)
[1] => Array
(
[names] => ddd
[staus] => 1
)
[2] => Array
(
[names] => ddd
[staus] => 1
)
)
如何过滤相同的值
变成这样
Array
(
[0] => Array
(
[names] => abc
[staus] => 1
)
[1] => Array
(
[names] => ddd
[staus] => 1
)
) 展开
展开全部
$tmp=array();
$s=array();//你的数组
foreach($s as $k=>$v){
if(in_array($v['name'],$tmp)){
unset($s[$k]);
}
$tmp[]=$v['name'];
}
var_dump($s);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function multi_unique($array) {
foreach ($array as $k=>$na)
$new[$k] = serialize($na);
$uniq = array_unique($new);
foreach($uniq as $k=>$ser)
$new1[$k] = unserialize($ser);
return ($new1);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询