Latest web development tutorials

PHP max () function

PHP Math Reference PHP Math Reference

Examples

() Function to find the maximum value by max:

<?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)));
?>

Running instance »

Definition and Usage

max () function returns the maximum value in an array, or a few specified maximum value.


grammar

max( array_values );

or

max( value1,value2,... );

参数 描述
array_values 必需。规定一个包含值的数组。
value1,value2,... 必需。规定要比较的值(至少两个值)。

technical details

return value: The maximum value.
Return type: Mixed
PHP version: 4+


PHP Math Reference PHP Math Reference