开发者

php max function to get name of highest value?

开发者 https://www.devze.com 2023-03-31 14:55 出处:网络
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?

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 ma开发者_Python百科x(array_keys($total));

Thanks!!


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))]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号