PHP - max
Trieda
Metóda - max
(PHP 4, PHP 5, PHP 7)
The max() function returns the highest value (maximum). The
function does not have a fixed number of parameters.
Procedurálne
- function max (array $values, mixed $value1, mixed $value2, mixed $...) : mixed
- function max (array $values, mixed $value1, mixed $value2, mixed $...) : mixed
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $values | array | An input value. | |
| $value1 | mixed | An input value. | |
| $value2 | mixed | An input value. | |
| $... | mixed | Additional input values. |
Mávratovej hodnoty
Vracia: mixed
The highest value.
Príklady
<?php
$array = [
[50, 2, 91],
[-5, 8, 0],
["dddd", "ccc", "a", "bb"],
[TRUE, FALSE, NULL],
[[5, 8, 4], [2, 1, 3]],
[["ITnetwork", "text", "PHP"],[2, 1, 3], 8]
];
foreach ($array as $value) {
$max = max($value); // returns the highest value
echo ("input value = ");
var_dump($value);
echo ("output value = ");
var_dump($max);
echo ("<br />");
}
