Comparing a float with an integer can have problems. You could try something like:
if(abs($i - $target) < .00001) { //then they are essentially equal } Kirk > -----Original Message----- > From: James E Hicks III [mailto:[EMAIL PROTECTED] > Sent: Friday, March 14, 2003 11:22 AM > To: [EMAIL PROTECTED] > Subject: [PHP] IF statement madness > > > Help save my sanity! What can I do to the IF statement in the > following code to > make it print the line that says "By God they are equal in > value."? I have tried > the following changes; > > 1. using === instead of == > 2. placing (float) in front of the $i and $target > inside and before the IF > statement. > > <? > $start = 215; > $end = 217; > $target = 216; > for ($i=$start; $i<=$end; $i+=.1){ > if ( $i == $target ){ > echo ("<BR>$i - $target, By God, the are > equal in value."); > } else { > echo ("<BR>$i - $target, Eternal Damnation, > they aren't > equal!"); > } > } > ?> > > > James E Hicks III > Noland Company > 2700 Warwick Blvd > Newport News, VA 23607 > 757-928-9000 ext 435 > [EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php