note 118838 added to class.iterator
| From: | Anonymous | Date: | Sun, 14 Feb 2016 12:52:01 +0000 |
| Subject: | note 118838 added to class.iterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204939@lists.php.net to get a copy of this message | ||
An interesting fact that I didn't read in the doc:
the key() method is called only if your foreach loop needs it.
For instance, the following loop calls the key() method:
<?php
foreach($it as $key => $value) {
var_dump($key, $value);
echo "\n";
}
?>
But the following loop doesn't:
<?php
foreach($it as $value) {
var_dump($value);
echo "\n";
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 89.86.19.161
----
Manual Page -- http://php.net/manual/en/class.iterator.php
Edit -- https://master.php.net/note/edit/118838
Del: integrated -- https://master.php.net/note/delete/118838/integrated
Del: useless -- https://master.php.net/note/delete/118838/useless
Del: bad code -- https://master.php.net/note/delete/118838/bad+code
Del: spam -- https://master.php.net/note/delete/118838/spam
Del: non-english -- https://master.php.net/note/delete/118838/non-english
Del: in docs -- https://master.php.net/note/delete/118838/in+docs
Del: other reasons-- https://master.php.net/note/delete/118838
Reject -- https://master.php.net/note/reject/118838
Search -- https://master.php.net/manage/user-notes.php