Max () returns the maximum value.
Syntax
Max (x, y) parameter description
X is required. A number.
Y is required. A number.
Description
Max () returns the maximum value in the parameter.
If there is only one parameter and it is an array, max () returns the maximum value of this array. If the first parameter is an integer, string, or floating point number, at least two parameters are required and max () returns the largest of these values. You can compare an infinite number of values.
Echo max (, 7); // return 7
Echo"
";
Echo max (array (2, 4, 5); // returns 5
Echo"
";
Echo max (0, 'Hello'); // return 0
Echo"
";
Echo max ('hello', 0); // return hello
Echo"
";
Echo max (-1, 'Hello'); // return hello
Echo"
";
$ Val = max (array (2, 4, 8), array (2, 5, 7); // returns the second array
Print_r ($ val );
Echo"
";
$ Val = max ('string', array (, 7), 42); // returns an array
Print_r ($ val );
/*
Min () returns the minimum value.
Syntax
Min (x, y) parameter description
X is required. A number.
Y is required. A number.
Description
Min () returns the smallest value in the parameter.
If there is only one parameter and it is an array, min () returns the smallest value in the array. If the first parameter is an integer, string, or floating point number, at least two parameters are required and min () returns the smallest of these values. You can compare an infinite number of values.
*/
Echo min (2, 3, 1, 6, 7); // 1
Echo"
";
Echo min (array (2, 4, 5); // 2
Echo"
";
Echo min (0, 'Hello'); // 0
Echo"
";
Echo min ('hello', 0); // hello
Echo"
";
Echo min ('hello',-1); //-1
Echo"
";
$ Val = min (array (, 8), array (, 1); // returns the first array
Print_r ($ val );
Echo"
";
$ Val = min ('string', array (, 7), 42); // return string
Print_r ($ val );