I think this is a simple Q. Here is code1: for ($i=0;$i<9119;$i++){ do_something(); }
Here is code2: $i=0; while($i<9119){ do_something(); $i++; }
Can code2 instead of code1 anyway? And which is faster(or better)? Sorry for my english!!
Both codes will have the same effect. I think there isn't much difference in speed. But I would use the first code. If you use the second code it always has to test if the condition is still true. In de first code it does it 9119 times. You should a 'while' when you don't now how many times the statement should be executed. But that's my opinion.