从PHP阵列获取最小值和最大值 [英] Getting the min and max values from a PHP array

查看:93
本文介绍了从PHP阵列获取最小值和最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个内置的PHP函数,可以让你从一个PHP数组得到最小值和最大值?

Is there a built in PHP function that will allow you get the minimum and maximum values from a PHP array?

如果没有,什么是做这行的一般情况的最有效方法是什么?

If not, what's the most efficient way of doing this for the general case?

推荐答案

分钟并的max

$array = array(1, 2, 3);

$min = min($array);
$max = max($array);

这篇关于从PHP阵列获取最小值和最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆