I have an array which contains duplicate values. I want to sort the array so that the values with the most duplicates appear first in line.
I want an output like:
Rihanna
U2
Becca
Taylor Swift
My file that contains data:
rihanna
rihanna
rihanna
rihanna
taylor swift
becca
becca
u2
u2
u2
My code as is which wont work:
$input = file_get_contents('files');
$input = explode("\n", $input);
$acv = array_count_values($input);
$acv = arsort($acv);
$result = array_keys($acv);
print_r($acv); //Outputs Blank
print_r(array_unique($input));but doesnt sort by order i want. Returns:Array ( [0] => rihanna [4] => taylor swift [5] => becca [7] => u2 [10] => )