min() : Minimum number

Find the lowest value with min()

min() returns the lowest value from the supplied arguments or from an array.

$temperatures = [28.4, 25.7, 31.2, 26.1];
echo min($temperatures); // 25.7

Use values of compatible types when possible. Mixing unrelated types can make comparisons harder to reason about.

echo min(4,8,2); // 2 
echo "<br>";
echo min(5,-1,0); // -1
echo "<br>";
echo min(2,0,-3); //-3
echo "<br>";
echo min(array(4,6,1)); // 1
echo "<br>";
Syntax
min($value1, $value2, ...)
We can get the minimum value from two or more comparable values by using min().
<?Php
echo min(-5.8,5,44,-56); //Output is -56
?> 

Comparing strings with min()

When all values are strings, min() compares them using PHP's normal string comparison rules. Avoid mixing strings and numbers in the same call because type juggling can make the result difficult to interpret.

$smallest = min('apple', 'banana', 'cherry');
echo $smallest; // apple

MIN function with Array

<?Php 
echo min(array(-6,8,-22,3,15,-5)); //Output is -22
?>

Example: Finding the Minimum of Multiple Arguments

$min_value = min(3, 9, 2, 5, 10);
echo $min_value;  // Output: 2

Example: Finding Minimum Value in an Array

$numbers = [12, 45, 3, 9, 27];
echo min($numbers);  // Output: 3

Example: Comparing Strings

$result = min("apple", "banana", "cherry");
echo $result;  // Output: apple (based on lexicographic order)

Read More on max value of Array
Math Functions max() function


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer