for loop with continue
| From: | surya prakash | Date: | Fri, 18 Sep 2009 06:30:17 +0000 |
| Subject: | for loop with continue | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-1092@lists.php.net to get a copy of this message | ||
Dear PHP people,
1.
2. for ($i = 0; $i < 5; $i++){
3. if ($i == 2)
4. continue;
5. print "$i<br />";
6. }
the above code outputs
0
1
3
4
but the "continue" definition in the PHP
manual(http://www.php.net/manual/en/control-st
.... ntinue.php<http://www.php.net/manual/en/control-structures.continue.php>)
tells that the control will check the condition whenever it encounters the
"continue" statement. According that definition control should check the
condition then the program should output like
0
1
and $i value is 2(since control should go to check the condition) forever
then the loop should become infinite...
But i thought that according for loop definition control will go to count
variable and increments the $i value to 3 and checks the condition that is
way it may give the result like
0
1
3
4
am I right? please clarify that the "continue" definition regarding for
loop....
and have a look at
http://forums.devnetwork.net/viewtopic.php?f=1&t=106401&p=567532#p567532
Thank you.
Surya