Repair Bad Credit - Advertising - Share Prices - Halloween Costumes - Windows registry

PDA

View Full Version : Comparing values, finding largest one.


Greg-J
Mar 21st 2006, 2:00 pm
I'm not sure of the best way to go about doing this.

I have 4 values ($strings) and must set a fifth value to the highest numerical value of the 4 preceding. I'm not sure if I should put them in to an array and then find the highest number in that array, or if there is a simpler method.

For reference the values are:
$rtl
$rtr
$rbr
$rbl

and the largest number of those values will be set to $sz


Thank you an advance for your help.

rvarcher
Mar 21st 2006, 2:12 pm
I would do this:

$sz = 0;
if ( $rtl > $sz ) $sz = $rtl;
if ( $rtr > $sz ) $sz = $rtr;
if ( $rbr > $sz ) $sz = $rbr;
if ( $rbl > $sz ) $sz = $rbl;

Greg-J
Mar 21st 2006, 2:21 pm
Thank you for your reply. I did end up finding a solution though.

$sz = max($rtl, $rtr, $rbr, $rbl);

rvarcher
Mar 21st 2006, 3:31 pm
That's cool. Learn something new everyday.