westonlea7 Posted March 30, 2008 Share Posted March 30, 2008 so, tell me why does the following script <?php $meh = 1; print "key" . $meh . "=\$keys[" . $meh . "]"; ?> give the following result, key1=$keys[1] yet the for loop with the exact same code in the center <?php for ( $counter = 0; $counter > 5; $counter++){ print "key" . $counter . "=\$keys[" . $counter . "]"; } ?> doesn't give anything when viewed in my browser? ??? Link to comment https://forums.phpfreaks.com/topic/98688-the-one-and-only-mysterious-for-loop/ Share on other sites More sharing options...
BlueSkyIS Posted March 30, 2008 Share Posted March 30, 2008 because your for loop is hosed. it says "while $counter > 5" but $counter starts at 0 (which is NOT greater than 5), so the loop is exited. for ( $counter = 0; $counter > 5; $counter++){ should be something more like: for ( $counter = 0; $counter < 5; $counter++){ Link to comment https://forums.phpfreaks.com/topic/98688-the-one-and-only-mysterious-for-loop/#findComment-505060 Share on other sites More sharing options...
westonlea7 Posted March 30, 2008 Author Share Posted March 30, 2008 lol, wow im and idiot....... ty Link to comment https://forums.phpfreaks.com/topic/98688-the-one-and-only-mysterious-for-loop/#findComment-505066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.