echo max(4,8,2); // 8
echo "<br>";
echo max(5,-1,0); // 5
echo "<br>";
echo max(2,0,-3); // 2
echo "<br>";
echo max(array(4,6,1)); // 6
echo "<br>";
echo max('plus2net',5,-2);// plus2net
echo "<br>";
echo max('abcd',5,0);// abcd
echo "<br>";
echo max('hello', 1); // hello
echo "<br><BR>";
echo max(0, 'hello'); // hello
echo "<br>";
echo max('hello', 0); // hello
Syntax
MAX(value1,value2,value3....);
We can get maximum value or highest number between two variables or two numbers by using max function. We can use more than two numbers also. Here is the code.
<?Php
echo max(5,25,6,-22,-66); // Output is 25
?>
<?Php
echo max(-2.5,'plus2net'); // Output plus2net
echo max(0,'plus2net'); // Output is 0, when values are equal the order decides the output
echo max(3,'plus2net'); //Output is 3
?>
<?Php
echo max(array(3,15,-5)); //Output is 15
?>
Read More on max value of Array