From: ian_mclaughlin at blueyonder dot co dot uk
Operating system: Win32
PHP version: 4.3.9
PHP Bug Type: Scripting Engine problem
Bug description: Array assignment with array_multisort
Description:
------------
this code gives the impression that array assignment is actually done by
pointer sharing, when it should be done by copying.
Reproduce code:
---------------
<?php
//
$master_A=array(1,2,4,3);
$master_B=array(1,3,2,4);
$A = $master_A;
$B = $master_B;
echo"<br/>BEFORE MULTISORT";
echo"<br/>master_A<br/>";
print_r($master_A);
echo"<br/>master_B<br/>";
print_r($master_B);
array_multisort($A, $B);
echo"<br/>AFTER MULTISORT";
echo"<br/>master_A<br/>";
print_r($master_A);
echo"<br/>master_B<br/>";
print_r($master_B);
?>
Expected result:
----------------
BEFORE MULTISORT
master_A
Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 3 )
master_B
Array ( [0] => 1 [1] => 3 [2] => 2 [3] => 4 )
AFTER MULTISORT
master_A
Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 3 )
master_B
Array ( [0] => 1 [1] => 3 [2] => 2 [3] => 4 )
Actual result:
--------------
BEFORE MULTISORT
master_A
Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 3 )
master_B
Array ( [0] => 1 [1] => 3 [2] => 2 [3] => 4 )
AFTER MULTISORT
master_A
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 )
master_B
Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 2 )
--
Edit bug report at http://bugs.php.net/?id=30587&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30587&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30587&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30587&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30587&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30587&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30587&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30587&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30587&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30587&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30587&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30587&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30587&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30587&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30587&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30587&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30587&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30587&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30587&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30587&r=mysqlcfg