php中一维或多维数组去除重复项
2个回答
展开全部
方案一
$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);
都是刚刚我实验出来的 都可以封装起来用递归实现多维去掉重复项
$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);
都是刚刚我实验出来的 都可以封装起来用递归实现多维去掉重复项
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询