Page 2 of 2

Posted: Sat Oct 21, 2006 10:06 am
by AKA Panama Jack
That's probably because English isn't their native language.

Posted: Sat Oct 21, 2006 10:40 am
by jayshields
Yeah, I saw the TLD, but still, there's no explanation for the other quote.

Posted: Sat Oct 21, 2006 12:53 pm
by Christopher
AKA Panama Jack wrote:You should NEVER use the COUNT function in a FOR loop

Code: Select all

for ($i=0; $i < count($array); $i++) {}
Never? What about when you want count() executed every loop becaue you are changing the length of the array within the loop?

I agree it should not be used when iterating over the entire array. But never? ;)

I would also like to note that the speed of the loop instruction is often an insignificat part of the time it takes to execute the instructions within the loop.

Posted: Sat Oct 21, 2006 7:13 pm
by Hades
foreach will likely be faster due to the fact that it essentially does the same as you are doing in the for loop, but it is written in C and that makes it faster to execute ;)

Posted: Sat Oct 21, 2006 7:15 pm
by patrikG
Hades wrote:foreach will likely be faster due to the fact that it essentially does the same as you are doing in the for loop, but it is written in C and that makes it faster to execute ;)
All of PHP is written in C. What's the point you're making?