P
P
PageUp2019-05-02 14:35:50
PHP
PageUp, 2019-05-02 14:35:50

How to find the maximum value in an array formed by Array_push()?

Hello.
An array is formed as follows:
$massiv=array();
array_push($array, $peremen); // $peremen has integers taken from the loop. Different from 1 to 100
Find and display the maximum value from this array.
I do this:
$result = max($array);
echo $result.
But the value is empty. Am I doing everything right?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2019-05-02
@PageUp

sandbox.onlinephpfunctions.com/code/d674d8ca0109c2...

T
ThunderCat, 2019-05-02
@ThunderCat

$result = max(array); =>$result = max( $ massiv);
Use editors with syntax highlighting, such errors are generally caught at the IDE level.
PS: $massiv, $remen ... is it really impossible to see 2 words in the translator? What are the names?

U
user49981, 2019-05-02
@user49981

$massiv=array();
array_push($massiv, 6);
array_push($massiv, 2);
array_push($massiv, 7);
$result = $massiv ? max($massiv) : 'empty';
echo $result; // 7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question