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>";
echo min('plus2net',5,-2);// -2
echo "<br>";
echo min('abcd',5,0);// 0
echo "<br>";
echo min('hello', 1); // 1
echo "<br><BR>";
echo min(0, 'hello'); // 0
echo "<br>";
echo min('hello', 0); // 0
Syntax
MIN(value1,value2,value3 .....)
We can get minimum value or lowest number between two variables or two numbers by using man() function. .
<?Php
echo min(-5.8,5,44,-56); //Output is -56
?>
<?Php
min('plus2net',-1); // Output is -1
min('plus2net',0); // Output is plus2net
min('plus2net',1); // Output is plus2net
?>
Here the output may change with PHP version.
<?Php
echo min(array(-6,8,-22,3,15,-5)); //Output is -22
?>
$min_value = min(3, 9, 2, 5, 10);
echo $min_value; // Output: 2
$numbers = [12, 45, 3, 9, 27];
echo min($numbers); // Output: 3
$result = min("apple", "banana", "cherry");
echo $result; // Output: apple (based on lexicographic order)
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.