Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP max() Function

PHP max() Function

PHP Math Reference Manual PHP Math Reference Manual

Example

Find the maximum value with the max() function:

"); echo(max(22,14,68,18,15) . "
"); echo(max(array(4,6,8,10)) . "
"); echo(max(array(44,16,81,12))); ?>

Run Example »


Definition and Usage

The max() function returns the maximum value in an array, or the maximum of several specified values.


Syntax

max(

array_values

);

or

max(

value1,value2,...

);

Parameters Description
array_values Required. Specifies an array containing values.
value1,value2,... Required. Specifies the values to compare (at least two values).

Technical Details

Return Value: The maximum numeric value.
Return Type: Mixed
PHP Version: 4+

PHP Math Reference Manual PHP Math Reference Manual