php 数组去除重复值
我要把花红线的键值去过 只留下后面的两个键值 应该怎么实现
$arr=array(38,39,41,38,39,41,42,43);<br />$c=array_count_values($arr);<br />function foo($v){<br /> global $c;<br /> if($c[$v]==1){<br /> return true;<br /> }<br /> return false;<br />}<br />print_r(array_filter($arr,'foo'));
$ar = array(38, 39, 40, 41, 38, 39, 40, 41, 42, 43);<br />foreach(array_count_values($ar) as $k=>$v)<br /> if($v == 1) $res[] = $k;<br /><br />print_r($res);