From an array that looks something like the following, how can I get the index of the highest value in the array. For the array below, the desired result would be '11'.
Array (  => 14  => 9  => 7  => 7  => 4  => 6 )
My solution is:
$maxs = array_keys($array, max($array))
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
<?php $array = array(11 => 14, 10 => 9, 12 => 7, 13 => 7, 14 => 4, 15 => 6); echo array_search(max($array), $array); ?>
array_search() return values:
Returns the key for needle if it is found in the array, FALSE otherwise.
If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_keys() with the optional search_value parameter instead.