44 of 410 menu

The max Function

The max function finds the largest number among the parameters passed to it or the largest number among the elements of an array.

Syntax

max(first number, second number...);
max(array of numbers);

Example

Let's find the largest among the given numbers:

<?php echo max(1, 2, 3); ?>

The code execution result:

3

Example

Let's find the largest value in the array:

<?php echo max([1, 2, 3]); ?>

The code execution result:

3

See Also

  • the min function,
    which finds the smallest number
byenru