|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-06-26 12:55 UTC] andrea dot busia at axis-sv dot it
[2006-08-24 14:41 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 10:00:01 2025 UTC |
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" }