I was here just a while ago, I got this piece of code from someone who replied to someone else's question.
"There is a function to count the number of every value in an array. For example if $input was the array 1, dog, 2, 2, dog, 2, 3, 3, 4, 5, dog, 2, 5 then:
$counts = function array_count_values($input) would return an array of:
$counts[1] = 1
$counts[2] = 4
$counts[3] = 2
$counts[4] = 1
$counts[5] = 2
$counts[dog] = 3
You could then do something like:
foreach($count as $key => $value){
echo 'the value '.$key.' occurs in the array '.$value.' times.';
}"
now this works fine for what I need, but now I want to know how to sort the values that appear the most by most to least and then be able to pull the top three individually. Thanks for any help!
"There is a function to count the number of every value in an array. For example if $input was the array 1, dog, 2, 2, dog, 2, 3, 3, 4, 5, dog, 2, 5 then:
$counts = function array_count_values($input) would return an array of:
$counts[1] = 1
$counts[2] = 4
$counts[3] = 2
$counts[4] = 1
$counts[5] = 2
$counts[dog] = 3
You could then do something like:
foreach($count as $key => $value){
echo 'the value '.$key.' occurs in the array '.$value.' times.';
}"
now this works fine for what I need, but now I want to know how to sort the values that appear the most by most to least and then be able to pull the top three individually. Thanks for any help!