I'm having some problems 🙁 Here's my snippet of code:
$str = "12,2,13,7,5,10";
$array = explode(',', $str);
$counts = array_count_values($array);
while (list ($key, $val) = each ($counts))
{
echo "$key = $val<br>";
}
I need for the array in the while loop to be in sorted order by the $val. Trying to sort() on $array or $counts gives me all kinds of weird errors about "Variable passed to each() is not an array or object " and whatnot. What am I doing wrong?? How can I make this happen?