NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Finding highest value in variables

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-09-2006, 05:01 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



Finding highest value in variables


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
dkin69 is offline  
Old 02-09-2006, 07:44 PM   #2 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



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)
nasaboy007 is offline  
Old 02-09-2006, 07:46 PM   #3 (permalink)
NamePros Regular
Join Date: Jun 2003
Location: Louisiana, USA
Posts: 658
painperdu has a spectacular aura aboutpainperdu has a spectacular aura about
 



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;
}
painperdu is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Your highest value domain sold? ridesign1 Domain Name Discussion 20 12-31-2005 03:19 PM
String and variables lovelinuxlove Programming 2 10-31-2004 05:26 AM
How I fill javascript array with php variables? wiedzim CODE 0 03-31-2004 03:45 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:24 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger