获取数组中最重复的值

Rob*_*son 3 php arrays

我有一系列这样的数字:

$array = array(1,1,1,4,3,1);
Run Code Online (Sandbox Code Playgroud)

如何获得最重复值的计数?

Con*_*eet 13

这应该工作:

$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."
Run Code Online (Sandbox Code Playgroud)