Re: loop Q

From: Date: Fri, 24 Feb 2006 13:03:37 +0000
Subject: Re: loop Q
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-231019@lists.php.net to get a copy of this message
john@johnallsopp.co.uk wrote:
William Stokes wrote:
What does this do in a for loop? $counter+=1
I read it as if he'd come across this: for ($counter=0; $counter<$stopper; $counter+=1) { ... lots of code ... $counter+=1; } Which, I think, would increment the counter twice on each pass through. The line in the loop needs deleting. That's just how I read it.
be ware of making assumptions like that, for instance the loop could very well be: for ($counter=0; $counter<$stopper;) { // ... lots of code ... $counter+=1; } or for ($counter=0; $counter<$stopper;$counter+=1) { // ... lots of code ... } which are both valid.
Actually, I'm testing this list .. every time I post it never appears so I'm wondering whether this will / the problem's been fixed.
it got thru :-)
J


« previous php.general (#231019) next »