PHP min()函数

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

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程