Home >Backend Development >PHP Problem >What function in php can find the maximum value in an array?
The max() function in php can find the maximum value in an array. The function of this function is to return the maximum value in an array, or the maximum value among several specified values. Its usage syntax is "max( array_values);or max(value1,value2,...);".
The operating environment of this tutorial: windows10 system, PHP version 8.1, DELL G3 computer
What function in php can find the value in an array Maximum value?
The max() function in php can find the maximum value in an array.
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
array_values Required. Specifies an array containing values.
value1,value2,... Required. Specifies the values to be compared (at least two values).
Example:
Find the maximum value through 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))); ?>
Output:
10 68 10 81
Recommended learning:《PHP video tutorial》
The above is the detailed content of What function in php can find the maximum value in an array?. For more information, please follow other related articles on the PHP Chinese website!