Sorting an array
| From: | Dotan Cohen | Date: | Thu, 13 Sep 2001 06:59:18 +0000 |
| Subject: | Sorting an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-67149@lists.php.net to get a copy of this message | ||
I'm trying to sort a listing of albums alphabetically
for LyricsList.com, the problem is that I want the
initial 'The' and 'A' in some albums (A Hard Days
Night, The Wall) to be ignored. So that the list will
look like:
Abbey Road
Dark Side Of the Moon
The Final Cut
A Hard Days Night
Kill 'em All
The Wall
ABC order, 'A' and 'The' negated. The info comes from
a database, in three calls:
// call albums that begin with letter $letter
$query = "SELECT * FROM albums WHERE album LIKE
'$letter%' ORDER BY album";
$result = mysql_query($query) or die(mysql_error());
// call albums that begin with letter A
$query_a = "SELECT * FROM albums WHERE album LIKE 'a'
ORDER BY album";
$result_a = mysql_query($query_a) or
die(mysql_error());
// call albums that begin with letter T
$query_t = "SELECT * FROM albums WHERE album LIKE 't'
ORDER BY album";
$result_t = mysql_query($query_t) or
die(mysql_error());
So I need to get just the albums from $result_t that
begin with 'The ' (easy regex) and from $result_a that
begin with 'A ' (easy regex), but puting the three of
them in order is proving beyond my skill.
Thanks in advance for any advise.
Dotan Cohen
__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/