[thelist] php - sorting multidimensional arrays
apathetic
timbooker at gmail.com
Tue Sep 28 06:08:17 CDT 2004
On Tue, 28 Sep 2004 11:26:17 +0100, Phil Cooper
<phil.cooper at zirconsoftware.co.uk> wrote:
> Essentially I'm trying to produce a league table. I have extracted data from the database tables and done some manipulation and have put this data into a multidimensional array.
>
> What I want do now is do a sort based on the number of wins so I can create an ordered league table and this is what I am struggling with. Can anyone point me to a good resource that explains, preferably in very simple English, how to do this?
In PHP, you can do this using usort, and defining your own sorting criteria:
http://www.php.net/manual/en/function.usort.php
Given that you are pulling the data from a MySQL table, it could also
be possible for you to add an ORDER BY to the query, and get the data
in the correct order straight from the database.
Tim
--
www.hyperlinkage.com - Free online RSS news reader
www.apatheticgenius.com
More information about the thelist
mailing list