PHP去重的简单写法
用array_flip实现去重效果
<?php
$arr =array("a"=>"a1","b"=>'b1',"c"=>"a2","d"=>"a1");$arr1 = array_flip($arr);print_r($arr1);//先反转一次,去掉重复值,输出Array ( [a1] => d[b1] => b [a2] => c ) 后者优先替代前面的$arr2 = array_flip($arr1);print_r($arr2);//再反转回来,得到去重后的数组,输出Array([d] => a1 [b] => b1 [c] => a2)?>
此去重效果比array_unique要快
转自:http://newmiracle.cn/?paged=7&cat=3