note 82468 added to control-structures.continue
| From: | bennet at mc dot edu | Date: | Sat, 12 Apr 2008 05:26:08 +0000 |
| Subject: | note 82468 added to control-structures.continue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138205@lists.php.net to get a copy of this message | ||
The first example above is:
<?php
while (list($key, $value) = each($arr)) {
if (!($key % 2)) { // skip odd members
continue;
}
do_something_odd($value);
}
?>
The comment could be misleading. The expression $key % 2 is true for odd values of $key, so the if
is true and the continue is executed when $key is even.
The comment could reasonably mean "for odd members, we skip the continue." But since I
associate running the continue with "skipping" the remainder of the loop, I would comment
this just the opposite way: "skip even members."
----
Server IP: 69.147.83.197
Probable Submitter: 75.65.162.32
----
Manual Page -- http://www.php.net/manual/en/control-structures.continue.php
Edit -- https://master.php.net/note/edit/82468
Del: integrated -- https://master.php.net/note/delete/82468/integrated
Del: useless -- https://master.php.net/note/delete/82468/useless
Del: bad code -- https://master.php.net/note/delete/82468/bad+code
Del: spam -- https://master.php.net/note/delete/82468/spam
Del: non-english -- https://master.php.net/note/delete/82468/non-english
Del: in docs -- https://master.php.net/note/delete/82468/in+docs
Del: other reasons-- https://master.php.net/note/delete/82468
Reject -- https://master.php.net/note/reject/82468
Search -- https://master.php.net/manage/user-notes.php