Home >>PHP Math Functions >PHP min() Function

PHP min() Function

PHP min() Function

PHP min() function is used to find the numerically minimum or lowest value in the given input array or the numerically maximum value of several specified values passed as arguments. It can accept an array or several numbers as an argument and return the numerically minimum value among all the passed parameters. Its return type is not fixed, it can be either an integer value or a float value based on the given input.

Syntax:

min(array());
 Or
min(value1,value2,...);

Parameter Values

Parameter Description
Array This is a required parameter. This parameter defines an array containing the values.
value1,value2,... This is a required parameter. This parameter defines the values to compare. It must be at least two values in this.

Here is an example of min() function in PHP:

<html>
<body>

<?php

echo min(1,2,3,4,5,6,7,8,9)."<br>";
echo min(22,44,67,12,45,63)."<br>";
echo min(63,63,834,165,15,11)."<br>";
echo min(73,1,47,82,74,19,22)."<br>";

?>

</body>
</html>
Output:
1
12
11
1

Here is another example of min() function in PHP:

<html>
<body>

<?php
$arr1 = array(1,2,3,4,5,6,7,8,9);
$arr2 = array(73,1,47,82,74,19,22);
$arr3 = array(63,63,834,165,15,11);

echo min(1,2,3,4,5,6,7,8,9)."<br>";
echo min(array(1,2,3,4,5,6,7,8,9))."<br>";
echo min($arr1)."<br>";
echo min(array(22,44,67,12,45,63))."<br>";
echo min($arr2)."<br>";
echo min($arr3)."<br>";

?>

</body>
</html>
Output:
1
1
1
12
1
11

No Sidebar ads