<?
/*
ABOUT:
This snippet will list all the files in the directory of your
choice, truncate the file extension, capitalize the first letter and
put it all in a drop down menu. The script will not list subdirectories so
all you see are the files in your directory.
Feel free to use or modify to your liking.
USAGE:
Change the $dirpath variable the directory you want to list.
AUTHOR:
Written by shockingbird
Visit www.glomer.net for more information
tate at tatenations dot com for any questions
*/
echo "<form>";
//Looks into the directory and returns the files, no subdirectories
echo "<select name='yourfiles'>";
//The path to the style directory
$dirpath = "/path/to/your/directory";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
//Don't list subdirectories
if (!is_dir("$dirpath/$file")) {
//Truncate the file extension and capitalize the first letter
echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))) . '</option>';
}
}
closedir($dh);
//Close Select
echo "</select>";
echo "</form>";
?> |