简体   繁体   English

如何获取数组的最高和最低值项?

[英]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)?

with min() / max() with min() / max()

$array = array();
$array['abc'] = 10;
$array['foo'] = 90;
$array['bar'] = 0;
$array['baz'] = 50;

echo " min: ", min($array);
echo " max: ", max($array);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从最高编号到最低编号(限3个项目)订购此数组? - How to order this array from highest number to lowest number limited for 3 items? 按键值对数组排序,然后获得数组中的5个最高和最低值 - Sort array by key value and then get 5 highest and lowest values in array JSON获得最高到最低价值的数据多数组 - JSON get highest to lowest value data multi array 如何从数组中从php中最高值到最低值排序的键中获取键? - How to get the keys from an array sorted from highest to lowest value in php? 如何在特定条件下提取数组中的最高和最低值? - How to extract the highest and lowest value in array with specific condition? 从中的关联数组中获得最大值,如果相等,则以其他值最低获得最高值 - getting the highest value from an associative array in and if equal, get the highest with the lowest other value 如何从PHP中的多维数组获取最高和最低值以及总和 - How to get the highest and lowest Values and sum from Multidimensional array in PHP 根据另一个值从多维数组中获取最高,第二高和最低 - Get the highest, second highest and the lowest from the multidimensional array based on another value 需要公式以获得一年中的最高和最低值 - Need formula to get lowest and highest value of a year PHP:获取变量中的最高和最低值 - PHP : get the highest and lowest value among variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM