helpme
helpme

Reputation: 1

php max function to get name of highest value?

I have a multi array and I am using the max function to return the highest value, however I'd like it to return the name? How can I do that?

$total = array($total_one => 'Total One', $total_two => 'Total Two');
echo max(array_keys($total));

Thanks!!

Upvotes: 0

Views: 260

Answers (1)

Brian Driscoll
Brian Driscoll

Reputation: 19635

First off, I think you have your keys and values reversed in your array. But nonetheless, you can do something like this:

echo $total[max(array_keys($total))]

Upvotes: 2

Related Questions