PHP :: Bug #30587 :: Array assignment with array_multisort
| Bug #30587 | Array assignment with array_multisort | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-10-27 20:09 UTC | Modified: | 2005-02-01 19:29 UTC |
|
||||||||||
| From: | ian_mclaughlin at blueyonder dot co dot uk | Assigned: | ||||||||||||
| Status: | Closed | Package: | Arrays related | |||||||||||
| PHP Version: | 4.3.9 | OS: | Win32 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-10-27 20:09 UTC] ian_mclaughlin at blueyonder dot co dot uk
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 )
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-11-16 11:44 UTC] ian_mclaughlin at blueyonder dot co dot uk
[2004-11-19 17:57 UTC] tony2001@php.net