I'd like to get the highest repetition index value in a string.
String example: 4,1,2,1,1,1,3,1,2,5,3
.
The result should be "1" , as it repeats 5 times.
I'd like to get the highest repetition index value in a string.
String example: 4,1,2,1,1,1,3,1,2,5,3
.
The result should be "1" , as it repeats 5 times.
Use the array_count_values()
function:
$array = array(4,1,2,1,1,1,3,1,2,5,3);
$total = array_count_values($array);
So, $total
will be an array as below:
$total ( [1] => 5 [2] => 2 [3] => 2 [4] => 1 [5] => 1 )