Bug #13269: References and Arrays
| From: | leonhard dot holz at t-online dot de | Date: | Wed, 12 Sep 2001 18:49:47 +0000 |
| Subject: | Bug #13269: References and Arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-65840@lists.php.net to get a copy of this message | ||
From: leonhard.holz@t-online.de
Operating system: Win98
PHP version: 4.0.5
PHP Bug Type: Scripting Engine problem
Bug description: References and Arrays
Another way of the references & array problem that shows up while copying
arrays:
<?
$aArray = Array();
$aArray["test"] = "Hello World!";
$rRef = &$aArray["test"];
echo $rRef."<br>";
$aArray2 = Array();
$aArray2["test"] = "Hello World 2!";
$aArray = $aArray2;
echo $aArray["test"]."<br>";
echo $rRef;
?>
The last echo should return "Hello World 2!" but it doesnt.
A workaround is to copy the arrays per key:
<?
while (list($key) = each($aArray2)) {
$aArray[$key] = $aArray2[$key];
}
?>
then all is ok.
--
Edit bug report at: http://bugs.php.net/?id=13269&edit=1