php max() function


  Translation results:

UK [mæks] US [mæks]

adv.Maximum value

php max() functionsyntax

Function:Find the maximum number from all parameters

Syntax: max(X,Y,Z) or max(array(X,Y,Z ))

Parameters: There is at least one parameter in the max function, it can be multiple parameters, or it can be an array.

Note: If there is only one parameter and it is an array, the maximum value in the array will be returned. If the first parameter is an integer, a string or a floating point number, at least two are required. Parameters, max will return the largest of these values, and the parameters can be unlimited values.

php max() functionexample

<?php
$i = 2;
$j = 9;
$k = 5;
$h = max($i,$j,$k);
echo "最大值是".$h;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

最大值是9
<?php
//获取数组中最大值的元素
$arr = array(15,16,88,54,79,33,159);
print_r(max($arr));
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

159

Popular Recommendations

Home

Videos

Q&A