PHP | max( ) Function
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.
Syntax:
max(array_values) or max(value1, value2, ...)
Parameters: This function accepts two different types of arguments which are explained below:
- array_values : It specifies an array containing the values.
- value1, value2, … : It specifies two or more than two values to be compared.
Return Value: The max() function returns the numerically maximum value.
Examples:
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:
<?php echo (max(12, 4, 62, 97, 26)); ?> |
Output:
97
Program 2:
<?php echo (max(array(28, 36, 87, 12)). "<br>"); ?> |
Output:
87
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.
Reference:
http://php.net/manual/en/function.max.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.set.has() Function
- D3.js | d3.map.set() Function
- p5.js | nf() Function
- p5.js | nfc() function
- PHP | Ds\Set contains() Function
- CSS | rgb() Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
- D3.js | d3.min() function
- p5.js | box() Function
- PHP | next() Function
- PHP | pos() Function
- PHP | key() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



