请教大神,php怎么数组去掉重复值???
举例
$array=array(1,2,3,3)
经过程序处理,一旦知道又重复数据,就删除,
最后结果我需要array(1,2),因为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 = array(1,2,3,3);
$t = array_diff($array,
array_keys(
array_diff(
array_count_values($array), array(1))
)
);
print_r($t);
How to use the print function in python
The difference between counta and count
How to solve the problem that cad cannot be copied to the clipboard
How to return to the homepage from an html subpage
what is oa system
How to use shuffle
apache startup failed
What are artificial intelligence technologies?