Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Finding highest value in variables

SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Namecheap AuctionsNamecheap Auctions
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
Close
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
Close
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
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back