PHP | min( ) Function
The min() function of PHP is used to find the lowest value in an array, or the lowest value of several specified values. The min() function can take an array or several numbers as an argument and return the numerically minimum value among the passed parameters. The return type is not fixed, it can be an integer value or a float value based on input.
Syntax:
min(array_values) or min(value1, value2, ...)
Parameters: This function accepts two different types of parameters which are explained below:
- array_values : It specifies an array containing the values.
- value1, value2, … : It specifies two or more than two values to be compared.
Return Value: The min() function returns the numerically minimum value.
Examples:
Input : min(12, 4, 62, 97, 26) Output : 4 Input : min(array(28, 36, 87, 12)) Output : 12
Below programs illustrate the working of min() in PHP:
Program 1:
<?php echo (min(12, 4, 62, 97, 26)); ?> |
Output:
4
Program 2:
<?php echo (min(array(28, 36, 87, 12))); ?> |
Output:
12
Important points to note :
- min() function is used to find the numerically minimum number.
- min() function can be used on two or more than two values or it can be used on an array.
- The value returned is of mixed data type.
Reference:
http://php.net/manual/en/function.min.php
Recommended Posts:
- PHP | cos( ) Function
- PHP | tan( ) Function
- PHP | key() Function
- PHP | each() Function
- PHP | next() Function
- PHP Ds\Map sum() Function
- PHP | sin( ) Function
- PHP | pi( ) Function
- PHP | max( ) Function
- PHP Ds\Map first() Function
- PHP | Ds\Set last() Function
- PHP | ord() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Set first() Function
- CSS | var() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



