Find Key in array based on stored values
Hey, im searching for a function(if there is one) that will allow me to get the key of a value in an array. Basically i have an array that is like
Now i need to find the highest value in the array which i know i can use
$tally[c1] = 3;
$tally[r1] = 5;
$tally[ps] = 1;
However what i need to find is i need to get r1, not the 5. There is probally an easy way using max to find the key using another array function but i've yet to be able to figure it out, any suggestions?
max($tally) //Returns 5
$key = array_search(max($tally), $tally);
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Thanks! knew it would be something simple and short.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)