这篇文章主要介绍PHP如何实现二维数组去重,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
二维数组去重
$arr = array( array('id'=>'2','title'=>'...','ding'=>'1','jing'=>'1','time'=>'...','url'=>'...','dj'=>'...'), array('id'=>'2','title'=>'...','ding'=>'1','jing'=>'1','time'=>'...','url'=>'...','dj'=>'...'));function about_unique($arr=array()){ $keys =array(); $temp = array(); foreach($arr[0] as $k=>$arrays) { $keys[] = $k; } //return $keys; foreach($arr as $k=>$v) { $v = join(",",$v); //降维 $temp[] = $v; } $temp = array_unique($temp); //去掉重复的内容 foreach ($temp as $k => $v){ $temp[$k] = explode(",",$v); } //return $temp; foreach($temp as $k=>$v) { foreach($v as $kkk=>$ck) { $data[$k][$keys[$kkk]] = $temp[$k][$kkk]; } } return $data; }
以上是“PHP如何实现二维数组去重”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程网行业资讯频道!