note 42282 added to control-structures.continue
| From: | www dot derosetechnologies dot com at rn2 dot php dot net | Date: | Tue, 11 May 2004 00:58:13 +0000 |
| Subject: | note 42282 added to control-structures.continue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69434@lists.php.net to get a copy of this message | ||
In the same way that one can append a number to the end of a break statement to indicate the
"loop" level upon which one wishes to 'break' , one can append a number to the
end of a 'continue' statement to acheive the same goal. Here's a quick example:
<?
for ($i = 0;$i<3;$i++) {
echo "Start Of I loop\n";
for ($j=0;;$j++) {
if ($j >= 2) continue 2; // This "continue" applies to the "$i" loop
echo "I : $i J : $j"."\n";
}
echo "End\n";
}
?>
The output here is:
Start Of I loop
I : 0 J : 0
I : 0 J : 1
Start Of I loop
I : 1 J : 0
I : 1 J : 1
Start Of I loop
I : 2 J : 0
I : 2 J : 1
For more information, see the php manual's entry for the 'break' statement.
----
Manual Page -- http://www.php.net/manual/en/control-structures.continue.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42282
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42282&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42282&report=yes
Search -- http://master.php.net/manage/user-notes.php