Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP Math min() function returns the minimum value in an array, or the minimum value among specified values.

Syntax

//version 1
min(array)

//version 2
min(value1, value2,...)

Parameters

array Required. Specify an array containing values to compare.
value1, value2,... Required. Specify values to compare.

Return Value

Returns the numerically minimum value.

Example:

In the below example, min() function is used to find out the minimum value among specified values.

<?php
$i = min(10, 20, 5, 100, 40, 50);
echo "The minimum value is: ".$i;
?>

The output of the above code will be:

The minimum value is: 5

Example:

In the below example, min() function to find out the minimum value in the array called MyArray.

<?php
$MyArray = array(101, 202, 15, 700, 430, 510);
$i = min($MyArray);
echo "The minimum value is: ".$i;
?>

The output of the above code will be:

The minimum value is: 15

❮ PHP Math Functions