#30587 [Csd->Ana]: Array assignment with array_multisort
| From: | tony2001@php.net | Date: | Thu, 02 Dec 2004 16:37:19 +0000 |
| Subject: | #30587 [Csd->Ana]: Array assignment with array_multisort | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-69734@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: Closed
+Status: Analyzed
-Bug Type: Scripting Engine problem
+Bug Type: Arrays related
Operating System: Win32
PHP Version: 4.3.9
Previous Comments:
------------------------------------------------------------------------
[2004-11-19 17:57:52] tony2001@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Yes, I was wrong, sorry.
This is fixed by now.
------------------------------------------------------------------------
[2004-11-16 11:44:21] ian_mclaughlin at blueyonder dot co dot uk
Thanks for your response.
Variables (master_A and master_B) change even though I have performed
no operation on them since assignment. All the documentation I can find
does not support this behaviour. If this actually is the expected
behaviour, please explain why.
------------------------------------------------------------------------
[2004-11-04 11:09:07] tony2001@php.net
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.
.
------------------------------------------------------------------------
[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