Mega Code Archive
Categories
/
Php
/
File Directory
List files in a directory, no subdirectories
echo "
"; //Looks into the directory and returns the files, no subdirectories echo "
"; //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 "
" . htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))) . '
'; } } closedir($dh); //Close Select echo "
"; echo "
"; ?>