Posted by josh.23.french on 11/03/06 04:21
A database would be the optimal solution at any rate but, assuming the
songs dir is in the current directory and $song_name is set:
<?php
function getfilearray($start) {
$dir=opendir($start);
while (false !== ($found=readdir($dir))) { $getit[]=$found; }
foreach($getit as $num => $item) {
if (is_dir($start.$item) && $item!="." && $item!="..") {
$output["{$item}"]=filearray($start.$item."/"); }
if (is_file($start.$item)) { $output["{$item}"]="FILE"; }
}
closedir($dir);
return $output;
};
$f_letter = substr($song_name,0,1);
if(is_dir("./songs/".$f_letter)){
$files = getfilesarray("./songs/".$fletter."/");
foreach($files as $name => $type){
if($name==$songname.".txt" && $type = "FILE")
$found = true;
};
};
};
if($found){
echo "<a href=\"index.php?song=$song_name\">$song_name</a>";
};
?>
Navigation:
[Reply to this message]
|