Skip to content

max ​

php
mixed max ( array $tablica )

mixed max ( mixed $wartosc1 , mixed $wartosc1 [, mixed $... ] ) Returns the greatest of the supplied values. If the only argument is an array, returns its greatest element. If multiple arguments are supplied, returns the greatest argument.

For strings, whether passed as arguments or in an array, character ASCII codes are compared. When two or more arrays are passed as arguments, the array with the most elements is selected.

Example 1:

php
$liczba1 = 30;
$liczba2 = 20;
$liczba3 = 19;
print("The greatest number in the set: {".$liczba1.",".$liczba2.",".$liczba3."}");
print(" is ".max($liczba1,$liczba2,$liczba3));

Result:

The greatest number in the set: {30,20,19} is 30

Example 2:

php
$zbior = array(33,17,47,33);
print("The greatest number in the set: \n");
print_r($zbior);
print("is: ".max($zbior));

Result:

The greatest number in the set:
Array
(
    [0] => 33
    [1] => 17
    [2] => 47
    [3] => 33
)
is: 47