w3resource

PHP: min() function

Description

The min() function is used to find the lowest value from a set of expression.

Version:

(PHP 4 and above)

Syntax:

min(array1)
min(num1, num2, num3...)

If the first and only parameter is an array, it returns the lowest value in that array.

Parameters

Name Description Required /
Optional
Type
array1 Specified array Required Array
num1,num2...numn Specified numbers (at least two numbers). Required Mixed*

Return value:

Returns the numerically lowest value.

Value Type: Mixed*.

*Mixed: Mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Pictorial Presentation

php-math-min()

Example:

<?php
echo "minimum value of 4, 14, 3, 5, 14.2 is ". 
min(4,14,3,5,14.2) . "<br />" ;
echo "minimum value of 4, -14, 2, 5, 7 is " . 
min(4,-14,2,5,7) . "<br />" ;
echo "minimum value of .1, .001, .2, -.5 is " . 
min(.1,.001,.2,-.5);
?>

Output:

minimum value of array(4, 14, 3, 5, 14.2) is 3
minimum value of 4, -14, 2, 5, 7 is -14
minimum value of .1, .001, .2, -.5 is -0.5 

View the example in the browser

See also

PHP Function Reference

Previous: max
Next: mt_getrandmax



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/min.php