note 35795 added to control-structures.for
| From: | php at project2501 dot plus dot com | Date: | Mon, 15 Sep 2003 08:45:50 +0000 |
| Subject: | note 35795 added to control-structures.for | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56502@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/control-structures.for.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35795
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35795&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35795&report=yes