PHP max()Functions

PHP Math 参考手册PHP Math Reference Manual

Examples

Find the maximum value using the max() function:

<?php
echo(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)));
?>

Run example »

Definition and Usage

The max() function returns the maximum value in an array, or the maximum value among 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: Numeric maximum value.
Return type: Mixed
PHP version: 4+


PHP Math 参考手册PHP Math Reference Manual Other Extensions