note 21792 deleted from function.array-multisort by aidan

From: Date: Sun, 03 Oct 2004 10:59:19 +0000
Subject: note 21792 deleted from function.array-multisort by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77814@lists.php.net to get a copy of this message
Note Submitter: alex at spektrs dot lv ---- This example for sorting SQL results is very usefull, except the author mixed up the array_multisort() arguments : <?php //Get table output into $rows array $result = mysql_query("SELECT field1, field2 from table"); while ($rows[] = mysql_fetch_array($result)) {} //Sort on field2 foreach ($rows as $val) { $sortarray[] = $val['field2']; } array_multisort($sortarray,$rows); ?> //Now, $rows is sorted on field2

« previous php.notes (#77814) next »