thedevilspride
09-14-2003, 04:38 PM
So far I have:
<?php
$lstFileNames=array();
$lstFileTitles=array();
$file_names = array();
$lines = file ('/path/to/files/true_names.txt');
foreach ($lines as $line_num => $line)
{
$parts = explode('|',$line);
$file_names[$parts[0]] = $parts[1];
}
if ($handle = opendir('/path/to/files/midis/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo " <tr>";
echo " <td valign=\"top\" colspan=\"3\" width=\"95%\"><b><font color='#6B7B90'>" . $file_names[$file] . "</font></b></td>";
echo " </tr>";
if ($handle2 = opendir('/path/to/files/midis/' . $file)) {
while (false !== ($file2 = readdir($handle2))) {
if ($file2 != "." && $file2 != ".." && $file2 != "index.html") {
$filename = '/path/to/files/midis/' . $file . '/' . $file2;
echo " <tr>";
echo " <td valign=\"top\" width=\"65%\"><a href=\"http://www.thedevilspride.com/files/midis/$file/$file2\">";
echo " " . $file_names[$file2] . "</a></td>";
echo " <td width=\"5%\"> </td>";
echo " <td align=\"right\" valign=\"top\" width=\"35%\">" . number_format(filesize($filename)/1024)." KB" . "</td>";
echo " </tr>";
}
}
closedir($handle2);
}
echo "<tr>";
echo " <td valign=\"top\" width=\"65%\"> </td>";
echo " <td width=\"5%\"> </td>";
echo " <td align=\"right\" valign=\"top\" width=\"35%\"> </td>";
echo " </tr>";
}
}
closedir($handle);
}
?>
At the moment they are all sorted by date.
Does anyone know how I could sort the files by their filesnames?
I've tried sort() but not too sure how to get it to work.
<?php
$lstFileNames=array();
$lstFileTitles=array();
$file_names = array();
$lines = file ('/path/to/files/true_names.txt');
foreach ($lines as $line_num => $line)
{
$parts = explode('|',$line);
$file_names[$parts[0]] = $parts[1];
}
if ($handle = opendir('/path/to/files/midis/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo " <tr>";
echo " <td valign=\"top\" colspan=\"3\" width=\"95%\"><b><font color='#6B7B90'>" . $file_names[$file] . "</font></b></td>";
echo " </tr>";
if ($handle2 = opendir('/path/to/files/midis/' . $file)) {
while (false !== ($file2 = readdir($handle2))) {
if ($file2 != "." && $file2 != ".." && $file2 != "index.html") {
$filename = '/path/to/files/midis/' . $file . '/' . $file2;
echo " <tr>";
echo " <td valign=\"top\" width=\"65%\"><a href=\"http://www.thedevilspride.com/files/midis/$file/$file2\">";
echo " " . $file_names[$file2] . "</a></td>";
echo " <td width=\"5%\"> </td>";
echo " <td align=\"right\" valign=\"top\" width=\"35%\">" . number_format(filesize($filename)/1024)." KB" . "</td>";
echo " </tr>";
}
}
closedir($handle2);
}
echo "<tr>";
echo " <td valign=\"top\" width=\"65%\"> </td>";
echo " <td width=\"5%\"> </td>";
echo " <td align=\"right\" valign=\"top\" width=\"35%\"> </td>";
echo " </tr>";
}
}
closedir($handle);
}
?>
At the moment they are all sorted by date.
Does anyone know how I could sort the files by their filesnames?
I've tried sort() but not too sure how to get it to work.