[英]How to get the highest and lowest value items of an array?
In an array like this: 在这样的数组中:
$array['abc'] = 10;
$array['foo'] = 90;
$array['bar'] = 0;
$array['baz'] = 50;
How can I retrieve the highest value item (90 in the above example) and the lowest value (0 in above example)? 如何检索最高值项(上例中为90)和最低值(上例中为0)?
http://www.php.net/manual/en/function.min.php http://www.php.net/manual/en/function.min.php
echo min(2, 3, 1, 6, 7); // 1
http://www.php.net/manual/en/function.max.php http://www.php.net/manual/en/function.max.php
echo max(1, 3, 5, 6, 7); // 7
Hope that helps! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.