Max value in an array()

Hi Guys

Please help me

Suppose I have an array()

$colours = array('blue' => 15, 'red' => 21, 'green' => 55);

I want to find out the $colour with the highest value.

Is there a way to do this please without looping through the array()

Thanks
DD

Thank you so much, it worked for me

DD

or you could just [FPHP]asort[/FPHP] the array.

This should do the trick:


$maxs = array_keys($colours, max($colours));
$colour = $maxs[0];

We get the array keys of the max value (which returns an array itself), then take the first value.