#25359 [NEW]: array_multisort doen't work in a funciton if array is global

From: Date: Tue, 02 Sep 2003 11:58:16 +0000
Subject: #25359 [NEW]: array_multisort doen't work in a funciton if array is global
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-47058@lists.php.net to get a copy of this message
From: matschek at gmx dot de Operating system: Win32, Linux PHP version: 4.3.2 PHP Bug Type: Arrays related Bug description: array_multisort doen't work in a funciton if array is global Description: ------------ When using array_multisort in a funciton, and the array is set to "global", array_multisort fails to sort the array. Reproduce code: --------------- function does_work() { $data = array('first', 'fifth', 'second', 'forth', 'third'); $sort = array(1, 5, 2, 4, 3); array_multisort($sort, $data); print_r($data); } function does_not_work() { global $data; $data = array('first', 'fifth', 'second', 'forth', 'third'); $sort = array(1, 5, 2, 4, 3); array_multisort($sort, $data); print_r($data); } echo "function does_work():\n"; does_work(); echo "\n\nfunction does_not_work():\n"; does_not_work(); Expected result: ---------------- function does_work(): Array ( [0] => first [1] => second [2] => third [3] => forth [4] => fifth ) function does_not_work(): Array ( [0] => first [1] => second [2] => third [3] => forth [4] => fifth ) Actual result: -------------- function does_work(): Array ( [0] => first [1] => second [2] => third [3] => forth [4] => fifth ) function does_not_work(): Array ( [0] => first [1] => fifth [2] => second [3] => forth [4] => third ) -- Edit bug report at http://bugs.php.net/?id=25359&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25359&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25359&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25359&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25359&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25359&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25359&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25359&r=support Expected behavior: http://bugs.php.net/fix.php?id=25359&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25359&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25359&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25359&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25359&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25359&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25359&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25359&r=gnused

« previous php.bugs (#47058) next »