Dynadot โ€” .com Transfer

Finding highest value in variables

SpaceshipSpaceship
Watch

dkin69

Established Member
Impact
4
I have 3 variables I would like to check the value of each and select the one that is the highest. They must be atleast .05 or higher

I was thinking something like

if ($var1 <= .049 || $var2 <= .049 || $var3 <= .049 )
{

echo 'value to low';

}
else
{
this is where Im confused, how to select the variable with the highest value

}

any help is appreciated.

Thanks

Turk
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
well simply, u cud to this:

else if($var1 > $var2 || $var1 > $var3) {
echo('Var 1 is the highest.');
}
else if($var2 > $var1 || $var2 > $var3) {
echo('Var 2 is the highest.');
}
else if($var3 > $var2 || $var3 > $var1) {
echo('Var 3 is the highest.');
}


that wud go after ur part (where the else in ur statement where u got lost is)
 
0
•••
A couple ways off the top of my head:

1) Put the values into an array and use rsort()

ex: $numbers = array(34,65,23);
$sortnumbers = rsort($numbers,SORT_NUMERIC);
$highestnumber = $sortnumbers[0];

2) Process of elimination:

ex: if ($a > $b) {
$firstroundwinner = $a;
}else{
$firstroundwinner = $b;
}

if ($firstroundwinner > $c) {
$highestnumber = $firstroundwinner;
}else{
$highestnumber = $c;
}
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back