Re: incrementing in a for loop

From: Date: Mon, 12 Sep 2005 21:48:05 +0000
Subject: Re: incrementing in a for loop
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-222217@lists.php.net to get a copy of this message
Stephen Johnson wrote:
On 9/12/05 12:39 PM, "Peppy" <peppy@foxedge.net> 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

« previous php.general (#222217) next »