Re: loop Q

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



john@xxxxxxxxxxxxxxxxx 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux