#30587 [Opn->Bgs]: Array assignment with array_multisort
| From: | tony2001@php.net | Date: | Thu, 04 Nov 2004 10:09:10 +0000 |
| Subject: | #30587 [Opn->Bgs]: Array assignment with array_multisort | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-68678@lists.php.net to get a copy of this message | ||
ID: 30587
Updated by: tony2001@php.net
Reported By: ian_mclaughlin at blueyonder dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Win32
PHP Version: 4.3.9
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2004-10-27 20:09:56] 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 )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30587&edit=1