PHP gets the most out of three variables

Possible duplicate:
Return variable with highest value?

I am trying to find an easy way to find the highest number of 3 variables.

$1 = 100
$2 = 300
$3 = 200

of these three variables, I want to set the new variable as the highest ($ 2)

So:

$highest_number = 300
0
source share
1 answer
$highest_number = max($1, $2, $3);

OR

$values = array($1, $2, $3);
$highest_number = max($values);

Further information can be found in quickref for max

+10
source

Source: https://habr.com/ru/post/1527527/


All Articles