note 77467 deleted from function.scandir by felipe
| From: | felipe@php.net | Date: | Fri, 29 Aug 2008 23:27:23 +0000 |
| Subject: | note 77467 deleted from function.scandir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144006@lists.php.net to get a copy of this message | ||
Note Submitter: george at REMOVE-THIScommentsville dot com
----
Much simpler script to list all directories within a given directory, while removing the . and ..
<?php
$mydir = dir('/path/to/directory/'); //include the trailing slash here
while(($file = $mydir->read()) !== false) {
$upper = ucwords($file);
if(is_dir($mydir->path.$file) == true && $file != '.' && $file !=
'..') {
echo "<li><strong><a
href='$file'>$upper</a></strong></li>";
}
}
$mydir->close();
?>