note 78375 added to language.references.whatdo
| From: | Hlavac at osu1 dot php dot net | Date: | Tue, 09 Oct 2007 09:25:54 +0000 |
| Subject: | note 78375 added to language.references.whatdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131245@lists.php.net to get a copy of this message | ||
Watch out for this:
foreach ($somearray as &$i) {
// update some $i...
}
...
foreach ($somearray as $i) {
// last element of $somearray is mysteriously overwritten!
}
Problem is $i contians reference to last element of $somearray after the first foreach, and the
second foreach happily assigns to it!
----
Server IP: 212.24.129.51
Probable Submitter: 80.188.199.89
----
Manual Page -- http://www.php.net/manual/en/language.references.whatdo.php
Edit -- https://master.php.net/note/edit/78375
Del: integrated -- https://master.php.net/note/delete/78375/integrated
Del: useless -- https://master.php.net/note/delete/78375/useless
Del: bad code -- https://master.php.net/note/delete/78375/bad+code
Del: spam -- https://master.php.net/note/delete/78375/spam
Del: non-english -- https://master.php.net/note/delete/78375/non-english
Del: in docs -- https://master.php.net/note/delete/78375/in+docs
Del: other reasons-- https://master.php.net/note/delete/78375
Reject -- https://master.php.net/note/reject/78375
Search -- https://master.php.net/manage/user-notes.php