时间:2021-07-01 10:21:17 帮助过:5人阅读
数组值3也不要吗
数组值3也不要吗
array_unique()啊
$arr = array(1,2,3,3);
$str = implode('',$arr);
$arrres = array_unique($arr);
foreach($arrres as $k=>$v)
{
$num = substr_count($str,$v);
if($num == 1)
{
$res[] = $v;
}
}
print_r($res);
$array = array(1,2,3,3);$t = array_diff($array, array_keys( array_filter( array_count_values($array), function($v) { return $v>1;}) ) );print_r($t);Array
$arr = array(1,2,3,3);
$str = implode('',$arr);
$arrres = array_unique($arr);
foreach($arrres as $k=>$v)
{
$num = substr_count($str,$v);
if($num == 1)
{
$res[] = $v;
}
}
print_r($res);
$array = array(1,2,3,3);$t = array_diff($array, array_keys( array_filter( array_count_values($array), function($v) { return $v>1;}) ) );print_r($t);Array
$array = array(1,2,3,3);$t = array_diff($array, array_keys( array_filter( array_count_values($array), function($v) { return $v>1;}) ) );print_r($t);Array
稍稍简化一下
$array = array(1,2,3,3);$t = array_diff($array, array_keys( array_diff( array_count_values($array), array(1)) ) );print_r($t);
$array=array(1,2,3,3);
$a=array_count_values($array);
$item=array();
foreach($a as $k=>$v) if($v==1) $item[]=$k;
print_r($item);