note 100655 added to control-structures.foreach
| From: | marko dot crni at gmail dot com | Date: | Thu, 28 Oct 2010 11:27:57 +0000 |
| Subject: | note 100655 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173549@lists.php.net to get a copy of this message | ||
It took me a whole day of debuging to spot this problem between php versions. This code:
$aArray = array(
1 => null,
2 => null,
3 => null,
);
foreach($aArray as $key => &$val)
{
$val = "Some Value";
foreach($aArray as $Xkey => $Xval) {} // This causes the problem
}
var_dump($aArray);
In php 5.1.6:
array(3) {
[1]=>
string(10) "Some Value"
[2]=>
NULL
[3]=>
NULL
}
In php 5.3.2:
array(3) {
[1]=>
string(10) "Some Value"
[2]=>
string(10) "Some Value"
[3]=>
&string(10) "Some Value"
}
----
Server IP: 69.147.83.197
Probable Submitter: 89.216.29.120
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/100655
Del: integrated -- https://master.php.net/note/delete/100655/integrated
Del: useless -- https://master.php.net/note/delete/100655/useless
Del: bad code -- https://master.php.net/note/delete/100655/bad+code
Del: spam -- https://master.php.net/note/delete/100655/spam
Del: non-english -- https://master.php.net/note/delete/100655/non-english
Del: in docs -- https://master.php.net/note/delete/100655/in+docs
Del: other reasons-- https://master.php.net/note/delete/100655
Reject -- https://master.php.net/note/reject/100655
Search -- https://master.php.net/manage/user-notes.php