wright67uk Posted July 4, 2011 Share Posted July 4, 2011 I know this is very basic, but would any kind sole feel like explaining step by step whats happening in this code? while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; Quote Link to comment https://forums.phpfreaks.com/topic/241086-walking-through-a-while-loop/ Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2011 Share Posted July 4, 2011 It's simply storing each array (record) returned from the database as an element in the $nt[] array, then incrementing an integer as it loops through the resulting array in a foreach() loop. Without some context, it doesn't make much sense to do that . . . Quote Link to comment https://forums.phpfreaks.com/topic/241086-walking-through-a-while-loop/#findComment-1238379 Share on other sites More sharing options...
IrOnMaSk Posted August 1, 2011 Share Posted August 1, 2011 you should never walking through a while loop because if you're smaller than the loop, you'll find yourselfe walking through it till eternity untill you're bigger than the loop variable... Quote Link to comment https://forums.phpfreaks.com/topic/241086-walking-through-a-while-loop/#findComment-1250340 Share on other sites More sharing options...
AyKay47 Posted August 1, 2011 Share Posted August 1, 2011 you should never walking through a while loop because if you're smaller than the loop, you'll find yourselfe walking through it till eternity untill you're bigger than the loop variable... Quote Link to comment https://forums.phpfreaks.com/topic/241086-walking-through-a-while-loop/#findComment-1250397 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.