#29095 [NEW]: array_merge loses references
| From: | alex at avannaproductions dot com | Date: | Sun, 11 Jul 2004 17:16:04 +0000 |
| Subject: | #29095 [NEW]: array_merge loses references | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-62031@lists.php.net to get a copy of this message | ||
From: alex at avannaproductions dot com
Operating system: MacOS X 10.3
PHP version: Irrelevant
PHP Bug Type: Arrays related
Bug description: array_merge loses references
Description:
------------
I'm not sure if this is a bug or actual accepted
behavior, but array_merge seems to lose references. (I
would assume array_merge_recursive does too, but I've
not tested that.) I think it would be ideal behavior if
this did not happen, as I've just come upon a real world
situation where my desired behavior would be very
useful. Test on both PHP 4.3.6 and July 10th snapshot of
PHP 5.
Reproduce code:
---------------
$one=array(1,2,3);
$two=array(4,5,6);
$three=&$two;
foreach($one as $val) echo "$val<br>";
foreach($three as $val) echo "$val<br>";
echo "-------------<br>";
$four=array_merge($one,&$three);
$two[0]="x";
$two[1]="x";
$two[2]="x";
foreach($four as $val) echo "$val<br>";
Expected result:
----------------
1
2
3
4
5
6
-------------
1
2
3
x
x
x
Actual result:
--------------
1
2
3
4
5
6
-------------
1
2
3
4
5
6
--
Edit bug report at http://bugs.php.net/?id=29095&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29095&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29095&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29095&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29095&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29095&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29095&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29095&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29095&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29095&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29095&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29095&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29095&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29095&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29095&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29095&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29095&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29095&r=float