Re: incrementing in a for loop

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

 



Stephen Johnson wrote:

On 9/12/05 12:39 PM, "Peppy" <peppy@xxxxxxxxxxx> wrote:


for ($i = 1; $i <= 6; $i++) {
Is it possible to increment $i by 5?


for ($i = 1; $i <= 6; $i+5) {


that won't work; have you tried it?
Because $i++ assigns the result of $i+1 to $i, while yours does not assign anything to $i. This means you'll run an eternal loop ;)
to do what you showed, you'll need to change $i+5 to $i=$i+5 or $i += 5

- tul

--
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