I'm not sure if this is the most efficient way... (bad search algorithm) but it works. 🙂
<?
$myarray = array(0, 2, 7, 8, 400, 5, 3, 343, 43, 3);
$max_value = max($myarray);
for($i=0; $i<count($myarray); $i++)
{
if($myarray[$i] == $max_value)
$max_key = $i;
}
echo 'The max key is: ' . $max_key . ' with value: ' . $max_value;
?>
The results should be:
The max key is: 4 with value: 400