Return index of highest value in an array

Posted . Visible to the public.

My solution is:

$maxs = array_keys($array, max($array))
Note:
this way you can retrieve every key related to a given max value.

If you are interested only in one key among all simply use $maxs[0]

Profile picture of Alexandru Catalin Trandafir
Alexandru Catalin Trandafir
Posted by Alexandru Catalin Trandafir to Alexandru Catalin Trandafir's deck (2013-03-08 12:23)