Sorting an array
Hello people. `
As a rookie, I'm having problems with Asort(). In the script below I open a directory, read all the html files in this directory, then grabbing line 5 out of each one of them to create a link to them. the problem is I'm having a hard time sorting the links alphabeticaly.
<?php
$default_dir = "./";
function traverse_dir($dir) {
chdir($dir);
if(!($dp = opendir($dir))) die("Can't open $dir.");
while($file = readdir($dp)) {
if(substr($file, -5)== ".html"){
$filelines = file($file);
$links = $filelines[4];
$links = ereg_replace("<TITLE>", "", $links);
$links = ereg_replace("</TITLE>", "", $links);
echo "<a href=\"".$file."\">".$links."</a><BR>";
}}
closedir($dp);
}
?>
how would someone sort $link variable in this case? I tried alot of things, and something seems to escapes me because I cant seem to get it.
|