Ok, I am making a PHP script and in the script there is 4 variables, lets called them $r, $h, $g, and $s. Now each of these variables will be a number like
$r = 3
$s = 3
$g = 1
$h = 0
Now I am trying to find a quick way of comparing the variables where it selects the largest variable. If two or more of the variables are the same, then the script would randomly pick one.
I could do this in a very long way using if statements to compare each variable to others then using about 2094729423 more if statements to find out which ones are the highest and equal if there are any but I do not want to do that so I am wondering is there a way to find the largest variable and if two are the same and the highest then the script randomly selects one. If there is, how do I go about and doing it?