1
I would like to get the value of the highest repetition index in a string.
String example : 4,1,2,1,1,1,3,1,2,5,3
.
The result should be "1", because it repeats itself 5 times.
1
I would like to get the value of the highest repetition index in a string.
String example : 4,1,2,1,1,1,3,1,2,5,3
.
The result should be "1", because it repeats itself 5 times.
1
Use the function array_count_values()
:
$array = array(4,1,2,1,1,1,3,1,2,5,3);
$total = array_count_values($array);
Thus, $total
will be a array as below:
$total ( [1] => 5 [2] => 2 [3] => 2 [4] => 1 [5] => 1 )
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.