Bug #7762 Updated: array_multisort() doesn't always correctly reassign references between values

From: Date: Wed, 27 Feb 2002 02:40:06 +0000
Subject: Bug #7762 Updated: array_multisort() doesn't always correctly reassign references between values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1139@lists.php.net to get a copy of this message
ID: 7762 Updated by: yohgaki@php.net -Summary: array_multisort() doesn't always correctly reassign references between values Reported By: noog@libero.it -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Windows 98 SE (4.10.2222) PHP Version: 4.0.2 New Comment: The version of PHP that this bug was reported in is too old. Please try to reproduce this bug in the latest version of PHP (available from http://www.php.net/downloads.php If you are still able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Previous Comments: ------------------------------------------------------------------------ [2000-11-11 14:38:36] noog@libero.it #This is pretty strange. #I didn't even know how to describe this $db = array( -1 => array('field0', 'field1', 'field2'), 'field0' => array(9, 2, 4, 8), 'field1' => array(333, 111, 333, 1), 'field2' => array(101010, 1, 22, 1111) ); for($i=0;$i<4;$i++){ foreach($db[-1] as $fieldname){ $db[$i][$fieldname] = &$db[$fieldname][$i]; } } #will print the same value (2) echo $db['field0'][1]; echo $db[1]['field0']; #we change $db['field0'][1] $db['field0'][1] = 2000; #will still print the same value (2000) echo $db['field0'][1]; echo $db[1]['field0']; array_multisort($db['field0'], $db['field1']); #we change $db['field0'][1] $db['field0'][1] = 600; #will print 600 echo $db['field0'][1]; #will print 2000 echo $db[1]['field0']; #the two values have been 'unlinked'? /* PLEASE NOTE this will work: array_multisort($db[0], $db[1]); #we change $db['field0'][1] $db['field0'][1] = 600; #will print the same value (600) echo $db['field0'][1]; echo $db[1]['field0']; */ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=7762&edit=1

« previous php.bugs (#1139) next »