[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 02-09-2006, 04:01 PM   #1 (permalink)
NamePros Regular
 
dkin69's Avatar
 
Join Date: May 2005
Posts: 358
15.75 NP$ (Donate)

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, 06:44 PM   #2 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

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 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, 06:46 PM   #3 (permalink)
NamePros Regular
 
Join Date: Jun 2003
Location: Louisiana, USA
Posts: 665
33.75 NP$ (Donate)

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;
}
__________________
******dotbob.com******
Cheap Domain Name Registrations
**** -Dotbob.com
painperdu is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Your highest value domain sold? ridesign1 Domain Name Discussion 20 12-31-2005 02:19 PM
DownloadSex.us - Taking Offers - $25 is the Current highest Only 1 1/2 days to go. Miloj Adult Domains For Sale 2 04-30-2005 04:56 PM
String and variables lovelinuxlove Programming 2 10-31-2004 04:26 AM
How I fill javascript array with php variables? wiedzim CODE 0 03-31-2004 02:45 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 05:09 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85