The links section of my blog is generated from a php array because I’m too lazy to sort the list myself.
The current code is:
<?php
$links = array(
"Pewari's Prattle" =>"http://pewari.may.be"
,"Mitchell's LiveJournal" =>"http://www.livejournal.com/users/mjquinn"
,"Wintermute's Journal" =>"http://www.livejournal.com/users/wmute/"
,"Glazblog" =>"http://daniel.glazman.free.fr/weblog/"
,"Adot's notblog*" =>"http://www.mozillazine.org/weblogs/asa/"
,"Brinx" =>"http://www.brinx.org/"
,"famousamy" =>"http://famousamy.livejournal.com/"
,"sjd blog" => "http://www.stephsjournal.says.it/"
);
ksort ($links);
foreach($links as $title => $url)
{
echo "<a class='menu' href='$url' target='_blank'>$title</a>";
}
?>
i.e. it’s really simple. I just use the ksort() function to do the sort.
Question: how do I get it to do a case-insensitive sort without resorting to doing most of the work myself?
The question may become moot, as I’m considering converting it to a database system so that I can edit them using a simple on-line form rather than editing a file :)
Update
Of course, having linked to the function call in the manual, I started having a hunt around as it’s more fun that actually working!
The answer is to use the SORT_NUMERIC flag, which when I think about it, it pretty obvious… *sigh*
So, the correct call is
ksort($links, SORT_NUMERIC);
So I can now correct the title of famousamy‘s link :)
Update 2
Okay, I’m being dense; it’s still not working :)
So the original question still stands!