note 18671 added to function.array-multisort

From: Date: Thu, 31 Jan 2002 06:22:57 +0000
Subject: note 18671 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-26072@lists.php.net to get a copy of this message
if you have to sort a multidimensional array for example a mysql result try to make a normal sort on it. Its sorted by the first row. the example from above: $result = mysql_query("SELECT field1, field2 from table"); while ($rows[] = mysql_fetch_array($result)) {} sort($rows); //Now, $rows is sorted on field1 $result = mysql_query("SELECT field2, field1 from table"); while ($rows[] = mysql_fetch_array($result)) {} sort($rows); //Now, $rows should be sorted on field2 -- http://www.php.net/manual/en/function.array-multisort.php http://master.php.net/manage/user-notes.php?action=edit+18671 http://master.php.net/manage/user-notes.php?action=delete+18671 http://master.php.net/manage/user-notes.php?action=reject+18671

« previous php.notes (#26072) next »