Believe that a lot of students from c++/java/c# and so on, may make such a mistake:
Outside a large for loop, write a lot of code after, but also a loop, we do not want to throw another I, we in other languages are so dry, but in PHP this way, you will find that the code into a dead loop! What is the reason?
The original for statement is not a function, just a statement form, in PHP, two I are treated as global variables, each run to the end of the loop, I have been re-assigned to 7, of course, will never jump out of the loop.
My solution is to try to separate the self-increment variable names of each for loop, which can greatly avoid this problem. and use foreach as much as possible.
The above describes the PHP local variable and global variable interleaving (a) nested for the variable in the loop, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.