Introduction
In this article I will explain the min and max functions in PHP. Both functions are available as math functions. I will discuss the min() function first.
The "min()" function returns the number with the lowest value.
Syntax
|
min($value) |
| Parameter | Description |
| $value | Returns the lowest value |
Example
The following example shows how to use the min() function:
<?php
echo min(2, 3, 1, 6, 7)."<br>";
echo min(array(2, 4, 5))."<br>";
echo min(0, 'Hi..Gaye')."<br>";
echo min('Hi..Gaye', 0)."<br>";
echo min('Hi..Gaye', -1)."<br>";
$value = min(array(2, 4, 8), array(2, 5, 1));
$value = min('string', array(2, 5, 7), 42);
?>
Output



Join the conversation! Your thoughts help the community grow.