From: [EMAIL PROTECTED] Operating system: linux PHP version: 4.0.4 PHP Bug Type: Arrays related Bug description: array_multisort and passing by reference When called inside a function array_multisort changes the global variables instead of the local copy the function should be working with. <?php $sortKeys = array(3, 2, 4, 1, 5); $a = array(111 => '111', 222 => '222', 333 => '333', 444 => '444', 555 => '555'); echo "initial arrays:<br>"; echo "sortKeys: "; var_dump($sortKeys); echo "<br>"; echo "a: "; var_dump($a); echo "<br>"; echo "<br>"; msortWithRef($sortKeys, $a); echo "after msortWithRef:<br>"; echo "sortKeys: "; var_dump($sortKeys); echo "<br>"; echo "a: "; var_dump($a); echo "<br>"; echo "<br>"; msortWithoutRef($sortKeys, $a); echo "after msortWithoutRef:<br>"; echo "sortKeys: "; var_dump($sortKeys); echo "<br>"; echo "a: "; var_dump($a); echo "<br>"; function msortWithoutRef($array1, $array2) { array_multisort($array1, $array2); } function msortWithRef($array1, $array2) { array_multisort(&$array1, &$array2); } ?> output: initial arrays: sortKeys: array(5) { [0]=> int(3) [1]=> int(2) [2]=> int(4) [3]=> int(1) [4]=> int(5) } a: array(5) { [111]=> string(3) "111" [222]=> string(3) "222" [333]=> string(3) "333" [444]=> string(3) "444" [555]=> string(3) "555" } after msortWithRef: sortKeys: array(5) { [0]=> int(3) [1]=> int(2) [2]=> int(4) [3]=> int(1) [4]=> int(5) } a: array(5) { [111]=> string(3) "111" [222]=> string(3) "222" [333]=> string(3) "333" [444]=> string(3) "444" [555]=> string(3) "555" } after msortWithoutRef: sortKeys: array(5) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) } a: array(5) { [0]=> string(3) "444" [1]=> string(3) "222" [2]=> string(3) "111" [3]=> string(3) "333" [4]=> string(3) "555" } -- Edit bug report at: http://bugs.php.net/?id=12936&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]