I have an array:
Array
(
[0] => Alex
[1] => Michael
[2] => Harry
[3] => Dave
[4] => Michael
[5] => Victor
[6] => Harry
[7] => Alex
[8] => Mary
[9] => Mary
)
I want to write to a function that will return an array with elements that most number of time repeated. For example, the output array should have Alex, Micheal, Hary, and Mary because each one of them is repeated twice. IF Alex was repeated three times, then the output array should only have Alex.
function writeIn($ballot) {
$count = array_count_values($ballot);
arsort($count);
foreach($count as $c => $name) {
$arr[] = $name;
}
}