I have this code set to display files in a directory if they're songs. They get put into a list that doesn't organize in any order. I want to organize these songs by their file name. If I look into my FileZilla they files are organized by the name of the file just fine.
example:
- 01 - Song Title
- 02 - Song Title
- 03 - Song Title
The songs aren't saved in any database. I've tried putting the songs into an array and using sort() but that only outputs the word "Array" over and over. I may be doing it wrong.
you can see an example here how they get posted randomly: http://mixtapemonkey.com/mixtape?m=637
<?php
$mixtapeid = $_GET['m'];
$tb_name="mixtapes";
$data = mysql_query("SELECT * FROM $tb_name WHERE id='$mixtapeid'") or die(mysql_error());
$info = mysql_fetch_array($data);
if ($handle = opendir("mixtapes/zip/".$info['id'])) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "mixtapes/zip/".$info['id'] && $entry != "mixtapes/zip/".$info['id']) {
$item = "mixtapes/zip/".$info['id']."/".$entry."/";
if ($newhandle = opendir("mixtapes/zip/".$info['id']."/".$entry)) {
while (false !== ($newentry = readdir($newhandle))) {
if ($newentry != "mixtapes/zip/".$info['id']."/".$entry && $newentry != "mixtapes/zip/".$info['id']."/".$entry) {
$ext = substr($newentry, strrpos($newentry, '.') + 1);
if ($ext == "mp3" || $ext == "m4a")
{
echo "<li><a href='$item$newentry'>".basename($newentry, '.mp3')."</a></li>";
}
}
}
closedir($newhandle);
}
}
}
closedir($handle);
}
?>