php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5532 Aliasing to array element affecting value downstream
Submitted: 2000-07-12 13:52 UTC Modified: 2000-07-13 04:13 UTC
From: tom dot ferguson at uphs dot upenn dot edu Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Release Candidate 2 OS: WinNT 4.0
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: tom dot ferguson at uphs dot upenn dot edu
New email:
PHP Version: OS:

 

 [2000-07-12 13:52 UTC] tom dot ferguson at uphs dot upenn dot edu
unset($a);
unset($v);
unset($k);

$a = array('x'=>"p",'y'=>"q",'z'=>"r");

foreach($a as $k => $v){
  echo $k . " => " .$v . "<br>";
}

echo "<br>";

$v = $a['y'];
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

$v = &$a['y'];
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

reset($a);
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

foreach($a as $k => $v){
  echo $k . " => " .$v . "<br>";
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-13 04:13 UTC] stas at cvs dot php dot net
Well, yes, foreach values are not local to the loop. 
I do not think this is a bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 09:01:33 2025 UTC