Bug #13825: sort functions

From: Date: Thu, 25 Oct 2001 15:38:44 +0000
Subject: Bug #13825: sort functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-69005@lists.php.net to get a copy of this message
From: lee@mediawaveonline.com Operating system: linux, windows PHP version: 4.0.6 PHP Bug Type: Feature/Change Request Bug description: sort functions $test[0] = 0; $test[1] = 1; $test[2] = 2; asort($test); I hate this, a function should never modify a variable, it should return the new modified variable. they syntax should be $test = asort($test); there are good reasons or this. I hate needing a variable sorted for one command and having to make a temp var just todo that. $tmp = $test; asort($tmp); foreach( $tmp as $pos => $val ) where it could be. foreach( asort($test) as $pos => $val ) saves time and ledgibility. I understand its not easy to change the syntax now. if you wanted to make some work or yourself you could make this a php.ini option. if you want something simpler on your end, just make a new set of functions, thats what Ive done. function my_asort($array) { asort($array); return $array); } even if you dont want to ever include this into base php, at least make asort return the newly modified variable. $tmp = $test; foreach( asort($tmp) as $pos => $val ) Chris Lee lee@mediawaveonline.com -- Edit bug report at: http://bugs.php.net/?id=13825&edit=1

« previous php.dev (#69005) next »