note 58093 added to function.ksort

From: Date: Mon, 24 Oct 2005 08:10:26 +0000
Subject: note 58093 added to function.ksort
Groups: php.notes 
Request: Send a blank email to php-notes+get-97498@lists.php.net to get a copy of this message
Just to complete the comments made by ssb45. If the supplied array is an empty array, the value returned is NOT an array. All that is required is to pre-initialize the result. function natksort(&$aToBeSorted) { $aResult = array(); $aKeys = array_keys($aToBeSorted); natcasesort($aKeys); foreach ($aKeys as $sKey) { $aResult[$sKey] = $aToBeSorted[$sKey]; } $aToBeSorted = $aResult; return True; } ---- Manual Page -- http://www.php.net/manual/en/function.ksort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58093 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58093&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58093&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97498) next »