Find the maximum value with the max() function:
<?phpecho(max(2,4,6,8,10) . "<br>");echo(max(22,14,68,18,15) . "<br>");echo(max( array(4,6,8,10)) . "<br>");echo(max(array(44,16,81,12)));?>The max() function returns the maximum value in an array, or the maximum value among several specified values.
max( array_values );ormax( value1,value2,... );
parameter | describe |
---|---|
array_values | Required. Specifies an array containing values. |
value1,value2,... | Required. Specifies the values to be compared (at least two values). |
Return value: | Numerical maximum value. |
---|---|
Return type: | Mixed |
PHP version: | 4+ |