max () returns the maximum value.
grammar
max (x, y) Parameter Description
x Required. A few.
y necessary. A few.
Description
max () Returns the value with the highest value in the argument.
If there is only one parameter and an array, max () returns the largest value in the array. If the first argument is an integer, string, or floating point number, at least two arguments are required and max () returns the largest of these values. You can compare an unlimited number of values.
echo max (1,3,5,6,7); // returns 7
echo "<br>";
echo max (array (2,4,5)); // returns 5
echo "<br>";
echo max (0, 'hello'); // returns 0
echo "<br>";
echo max ('hello', 0); // return hello
echo "<br>";
echo max (-1, 'hello'); // return hello
echo "<br>";
$ val = max (array (2,4,8), array (2,5,7)); // returns the second array
print_r ($ val);
echo "<br>";
$ val = max ('string', array (2,5,7), 42); // returns an array
print_r ($ val);
/ *
min () returns the minimum value.
grammar
min (x, y) Parameter Description
x Required. A few.
y necessary. A few.
Description
min () Returns the smallest value in the argument.
If there is only one argument and an array, min () returns the smallest value in the array. If the first argument is an integer, string, or floating point number, at least two arguments are required and min () returns the smallest of those values. You can compare an unlimited number of values
* /
echo min (2,3,1,6,7); // 1
echo "<br>";
echo min (array (2,4,5)); // 2
echo "<br>";
echo min (0, 'hello'); // 0
echo "<br>";
echo min ('hello', 0); // hello
echo "<br>";
echo min ('hello', - 1); // - 1
echo "<br>";
$ val = min (array (2,4,8), array (2,5,1)); // returns the first array
print_r ($ val);
echo "<br>";
$ val = min ('string', array (2,5,7), 42); // return string
print_r ($ val);