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

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
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



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-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer