php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13269 References and Arrays
Submitted: 2001-09-12 14:49 UTC Modified: 2001-12-14 14:33 UTC
From: leonhard dot holz at t-online dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Win98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: leonhard dot holz at t-online dot de
New email:
PHP Version: OS:

 

 [2001-09-12 14:49 UTC] leonhard dot holz at t-online dot de
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 14:33 UTC] yohgaki@php.net
It works for me. I guess this is fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 17:01:27 2024 UTC