dd1313
1
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
dd1313
2
Thank you so much, it worked for me
DD
or you could just [FPHP]asort[/FPHP] the array.
r2d2
4
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.