php中一维或多维数组去除重复项

 我来答
lovelixinan
推荐于2016-03-26 · 超过15用户采纳过TA的回答
知道答主
回答量:121
采纳率:0%
帮助的人:66.5万
展开全部
方案一
$arr = array("0a","1b","2c","3d","4e","5f","6g","0a","2c","4e","6g","6g");
$arr1 = array_flip($arr);
$arr2 = array_flip($arr1);
print_r($arr2);
方案二
$arr = array("0a","1b","2c","3d","4e","5f","6g","0a","2c","4e","6g","6g");
$a = array_count_values($arr);
$b = array_keys($a);
print_r($b);
方案三
$arr = array("0a","1b","2c","3d","4e","5f","6g","0a","2c","4e","6g","6g");
foreach($arr as $k=>$v){
$arr1[$v] = $k;
$arr2 = array_flip($arr1);
}
print_r($arr2);
方案四
$arr = array("0a","1b","2c","3d","4e","5f","6g","0a","2c","4e","6g","6g");
$arr1 = array_unique($arr);
print_r($arr1);

都是刚刚我实验出来的 都可以封装起来用递归实现多维去掉重复项
来自:求助得到的回答
WoWnePiece
2012-12-21 · 超过23用户采纳过TA的回答
知道答主
回答量:73
采纳率:0%
帮助的人:36万
展开全部
array_unique($array);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式