PHP min

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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 :

  1. echo "minimum value of 4, 14, 3, 5, 14.2 is ".   

  2. min(4,14,3,5,14.2) . "
    " ;  

  3. echo "minimum value of 4, -14, 2, 5, 7 is " .   

  4. min(4,-14,2,5,7) . "
    " ;  

  5. echo "minimum value of .1, .001, .2, -.5 is " .   

  6. min(.1,.001,.2,-.5);  

  7. ?>  

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