From: [EMAIL PROTECTED] Operating system: Unix PHP version: 4.2.0 PHP Bug Type: Unknown/Other Function Bug description: Array_multisort don't work on GLOBAL array
Using array_multisort in a function don't work if the array is "global" (you can paste the following code) : <HTML> <HEAD> <TITLE></TITLE> </HEAD> <body> <? function t() { global $row; $file = fopen("file.txt","r") or die; while (!feof($file)) { $row[] = fgetcsv($file,80,";"); } /* $row[] like this Array ( [0] => Array ( [0] => 406 [1] => xxxxxxxxxxxxxxxxxxxx [2] => 5,72 ) [1] => Array ( [0] => 001 [1] => zzzzzzzzzzzzzzzzzzzzz [2] => 5,77 ) [2] => Array ( [0] => 402 [1] => aaaaaaaaaaaaaaaaaaaaa [2] => 13,71 ) [3] => Array ( [0] => 009 [1] => fffffffffffffffffffff [2] => 7,61 ) ) I want to sort it on aaa.../fff.../xxx.../zzz... */ fclose($file); foreach ( $row as $value ) { $sortarray[] = $value[1]; } /* $sortarray like this Array ( [0] => xxxxxxxxxxxxxxxxxxxx [1] => zzzzzzzzzzzzzzzzzzzz [2] => aaaaaaaaaaaaaaaaaaaa [3] => ffffffffffffffffffff ) */ // I try to use array_multisort($row,$sortarray); too array_multisort($sortarray,$row); print_r($row); // no change for $row[], until i remove global for $row; echo "<br>"; print_r($sortarray); /* $sortarray[], now like this Array ( [0] => aaaaaaaaaaaaaaaaaaaa [1] => ffffffffffffffffffff [2] => xxxxxxxxxxxxxxxxxxxx [3] => zzzzzzzzzzzzzzzzzzzz ) or no change if set to global too. */ } t(); ?> </body> </HTML> -- Edit bug report at http://bugs.php.net/?id=19617&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19617&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19617&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19617&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19617&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19617&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19617&r=support Expected behavior: http://bugs.php.net/fix.php?id=19617&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19617&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19617&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19617&r=globals