note 54231 added to function.natsort

From: Date: Tue, 28 Jun 2005 04:08:39 +0000
Subject: note 54231 added to function.natsort
Groups: php.notes 
Request: Send a blank email to php-notes+get-91049@lists.php.net to get a copy of this message
Here's an expansion of the natsort2d function that mbirth wrote. This one allows you to specify the key for sorting. <?php function natsort2d( &$arrIn, $index = null ) { $arrTemp = array(); $arrOut = array(); foreach ( $arrIn as $key=>$value ) { reset($value); $arrTemp[$key] = is_null($index) ? current($value) : $value[$index]; } natsort($arrTemp); foreach ( $arrTemp as $key=>$value ) { $arrOut[$key] = $arrIn[$key]; } $arrIn = $arrOut; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.natsort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54231 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54231&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54231&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91049) next »