Skip to content
Related Articles

Related Articles

PHP | max( ) Function

Improve Article
Save Article
  • Last Updated : 07 Mar, 2018
Improve Article
Save Article

The max() function of PHP is used to find the numerically maximum value in an array or the numerically maximum value of several specified values. The max() function can take an array or several numbers as an argument and return the numerically maximum value among the passed parameters. The return type is not fixed, it can be an integer value or a float value based on input.




max(value1, value2, ...)

Parameters: This function accepts two different types of arguments which are explained below:

  1. array_values : It specifies an array containing the values.
  2. value1, value2, … : It specifies two or more than two values to be compared.

Return Value: The max() function returns the numerically maximum value.


Input : max(12, 4, 62, 97, 26)
Output : 97

Input : max(array(28, 36, 87, 12))
Output : 87

Below programs illustrate the working of max() in PHP:

Program 1:

echo (max(12, 4, 62, 97, 26));



Program 2:

echo (max(array(28, 36, 87, 12)). "<br>");



Important points to note :

  • max() function is used to find the numerically maximum number.
  • max() function can be used on two or more than two values or it can be used on an array.
  • The value returned is of mixed data type.


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!