From:             andrea dot busia at axis-sv dot it
Operating system: Linux / WinXp
PHP version:      5.1.4
PHP Bug Type:     Arrays related
Bug description:  Original Array modified after copy

Description:
------------
First problem: If I Create an array setting an element to a string and
another element as a reference to the first, then copy the array into an
other variable, if i modify the second variable also the original array is
modified.

Second problem:
why the second code line ($a[0]="foo";) produces
  [0]=>
  &string(3) "foo"

instead of
  [0]=>
  string(3) "foo"

Thanks
Andrea Busia

Reproduce code:
---------------
<?
$a=array();
$a[0]="foo";
$a[1] =& $a[0];
var_dump($a);
$b=$a;
$b[0]="bar";
var_dump($a);
?>


Expected result:
----------------
array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  &string(3) "foo"
}
array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  &string(3) "foo"
}


Actual result:
--------------
array(2) {
  [0]=>
  &string(3) "foo"
  [1]=>
  &string(3) "foo"
}
array(2) {
  [0]=>
  &string(3) "bar"
  [1]=>
  &string(3) "bar"
}


-- 
Edit bug report at http://bugs.php.net/?id=37917&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37917&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37917&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37917&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37917&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37917&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37917&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37917&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37917&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37917&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37917&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37917&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37917&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37917&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37917&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37917&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37917&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37917&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37917&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37917&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37917&r=mysqlcfg

Reply via email to