listing directory and filtering
Posted on 2003-03-26
This is real easy for some but need help with this script. As it is now the script list all html files in a directory so it filters out all files except files ending in .html. I need the script to preform a couple more function and need help.
1) It needs to display just the name of the file without the extension (example: index.html would be diplayed as index but the link will point to index.html
2.) Filter out any .html files that have -days.html or -months.html and exclude those from the printed list (example: test-days.html or test-months.html)
Thanks in advance for anyones help.
Here is the code:
echo "Click on customer to view transfer stats<br>";
$handle = opendir('.');
$counter = 0;
while ($file = readdir($handle))
$the_type = strrchr($file, ".");
$allow_file = eregi("html",$the_type);
if ($file != "." and $file != ".." and $allow_file)
$myfiles[$counter] = $file;
echo "<br> <a href=\"$file\">$file</a>\n";