PHP min()函数
PHP min()函数用于找到最小值。
语法
min(array_values);
or
min(value1,value2,value3...);
参数 | 描述 | 类型 |
---|---|---|
array_values | 指定的数组 | 数组 |
value1,value2,value3…); | 指定两个或更多个值(至少两个数字)。 | 混合类型 |
示例1
<?php
num=min(4,14,3,5,14.2);
echo "Your number is =min(4,14,3,5,14.2)".'<br>';
echo "By using min() function Your number is : ".num;
?>
输出:
Your number is =max(4,14,3,5,14.2)
By using min function Your number is : 3
示例2
<?php
num=min(4,-14,3,-5,14.2);
echo "Your number is =min(4,-14,3,5,14.2)".'<br>';
echo "By using min() function Your number is : ".num;
?>
输出:
Your number is =min(4,-14,3,5,14.2)
By using min() function Your number is : -14
示例3
<?php
ar=array(14,-18,4,8,15.5);
echo "Your number is =min(14,-18,4,8,15.5)".'<br>';
echo "By using min() function Your number is : ".min(ar);
?>
输出:
Your number is =min(14,-18,4,8,15.5)
By using min() function Your number is : -18
示例4
<?php
ar=array(1=>15,3=>25,4=>13,5=>10);
echo "Your number is =min(1=>15,3=>25,4=>13,5=>10)".'<br>';
echo "By using min() function Your number is : ".min(ar);
?>
输出:
Your number is =min(1=>15,3=>25,4=>13,5=>10)
By using min() function Your number is : 10