max() function in PHP


The max() function Returns the maximum value of an array.

Syntax

max(arr_values);
or
max(val1,val2,...);

Parameters

  • arr_values − The array with values.

  • val1, val2 − The values to compare.

Return

The max() function Returns the maximum value of an array.

Example

 Live Demo

<?php
   echo (max(70, 89, 12, 34, 23, 66, 34));
?>

Output

89

Example

Let us see another example −

 Live Demo

<?php
   echo (max(array(70, 89, 12, 34, 23, 66, 34)));
?>

Output

89

Updated on: 27-Dec-2019

106 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements