note 35795 deleted from control-structures.for by danbrown

From: Date: Mon, 07 Dec 2009 16:08:27 +0000
Subject: note 35795 deleted from control-structures.for by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163663@lists.php.net to get a copy of this message
Note Submitter: php at project2501 dot plus dot com ---- just to clarify that you can 'chain' expr1, expr2 and expr3, for instance: <? for($i=0 , $j=10 ; $i<5 ; $i++ , $j+=5, $k=($i+$j)) { echo "i: $i<br />j: $j<br />k: $k<br /><br />"; } ?> produces: i: 0 j: 10 k: i: 1 j: 15 k: 16 i: 2 j: 20 k: 22 i: 3 j: 25 k: 28 i: 4 j: 30 k: 34 in case you need to do more than one operation per iteration. The reason $k does not start with a value of 10, is because expr3 ($k=($i+$j)) is evaluated at the -end- of each iteration.

« previous php.notes (#163663) next »