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()
Thank you so much, it worked for me
or you could just asort the array.
This should do the trick:
$maxs = array_keys($colours, max($colours));
$colour = $maxs;
We get the array keys of the max value (which returns an array itself), then take the first value.