php去重 去除一维或多维数组重复项的方法

2015年5月15日星期五 | | |

方案一
$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);

都是刚刚我实验出来的 都可以封装起来用递归实现多维去掉重复项
这些个方法可以有. 哈. 分享一下. 希望对你有用.
 
参考网络:http://zhidao.baidu.com/link?url=HwpIOHUjKyFyK8zfDEYmPqxPwqetnrurm1sK90zcYuTE2GmDhu2Rh7H2NNVHaNmpxzvz9Rsj6ypIBMppLsbKo_
 

0 评论:


所有文章收集于网络,如果有牵扯到版权问题请与本站站长联系。谢谢合作![email protected]