[英]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? 我有一个多数组,我使用max函数返回最高值,但我想它返回名称? How can I do that?
我怎样才能做到这一点?
$total = array($total_one => 'Total One', $total_two => 'Total Two');
echo max(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))]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.