Stooney Posted June 19, 2008 Share Posted June 19, 2008 The following for loop is stuck in an infinite loop. When I echo $i each loop it says it's value is 1 every time. So for some reason $i is not incrementing by the 7 it should. I am working with a csv file. It is just a long comma delimited file. There are 7 fields per row. $count=3819; $key=0; for($i=1; $i<=$count; $i+7){ echo $i.' '; $sql[$key]['biddernum']=$data[$i]; $sql[$key]['lname']=$data[$i+1]; $sql[$key]['fname']=$data[$i+2]; $sql[$key]['address']=$data[$i+3]; $sql[$key]['city']=$data[$i+4]; $sql[$key]['state']=$data[$i+5]; $sql[$key]['zip']=$data[$i+6]; $key++; } Example Output: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Quote Link to comment https://forums.phpfreaks.com/topic/110865-solved-for-loop/ Share on other sites More sharing options...
corbin Posted June 19, 2008 Share Posted June 19, 2008 You are not incrementing i by 7, you are simply evaluating i+7... That's the equivalent of doing: $i+7; You need to set i to i to 7.... $i = $i + 7; Or shorthand (which I would use) $i += 7; Quote Link to comment https://forums.phpfreaks.com/topic/110865-solved-for-loop/#findComment-568816 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.