How to find the maximum value in the generated array Array_push()?


Creates an array as follows:

array_push($massiv, $peremen); // $peremen has integers taken from the cycle. Different from 1 to 100
Need to find and display the largest value from this array.
I do so:
$result = max($massiv);
echo $result.

But value is empty. Am I doing it right?
March 20th 20 at 11:29
3 answers
March 20th 20 at 11:31
March 20th 20 at 11:33
$result = max(massiv); =>$result = max($massiv);
Use editors with syntax highlighting, such errors are generally on the level of IDE are caught.

PS: $massiv, $peremen ... is 2 words the interpreter can't see it? What is the name?
say thank you for not $a and not molmasse $mapelement PHP the regular season on the names included the region... - vicente.Abernathy commented on March 20th 20 at 11:36
March 20th 20 at 11:35
array_push($massiv, 6);
array_push($massiv, 2);
array_push($massiv, 7);
$result = $massiv ? max($massiv) : 'empty';
echo $result; // 7

Find more questions by tags PHPArrays