<分区>
我有一个这样的数字数组:
$array = array(1,1,1,4,3,1);
如何计算重复次数最多的值?
<分区>
我有一个这样的数字数组:
$array = array(1,1,1,4,3,1);
如何计算重复次数最多的值?
最佳答案
这应该有效:
$count=array_count_values($array);//Counts the values in the array, returns associatve array
arsort($count);//Sort it from highest to lowest
$keys=array_keys($count);//Split the array so we can find the most occuring key
echo "The most occuring value is $keys[0][1] with $keys[0][0] occurences."
关于php - 获取数组中重复次数最多的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10612126/