note 38876 added to function.natsort

From: Date: Fri, 09 Jan 2004 17:31:18 +0000
Subject: note 38876 added to function.natsort
Groups: php.notes 
Request: Send a blank email to php-notes+get-63223@lists.php.net to get a copy of this message
For those who want to natsort a 2d-array on the first element of each sub-array, the following few lines should do the job. <?php function natsort2d(&$aryInput) { $aryTemp = $aryOut = array(); foreach ($aryInput as $key=>$value) { reset($value); $aryTemp[$key]=current($value); } natsort($aryTemp); foreach ($aryTemp as $key=>$value) { $aryOut[] = $aryInput[$key]; } $aryInput = $aryOut; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.natsort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38876 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38876&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38876&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63223) next »