min() : Minimum number

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
?> 

MIN function with String

Strings are treated as 0 while comparing.
When two equal values are there the order decides which is minimum or lowest.
<?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.

MIN function with Array

<?Php 
echo min(array(-6,8,-22,3,15,-5)); //Output is -22
?>
Read More on max value of Array
Math Functions max() function
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here





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