note 37767 added to function.readdir
| From: | SteveMain at rn2 dot php dot net | Date: | Wed, 26 Nov 2003 01:53:30 +0000 |
| Subject: | note 37767 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60989@lists.php.net to get a copy of this message | ||
This will allow you to print out a total recursive directory listing no files just directories for
possible tree menues that need folder lists.
<?php
$DirectoriesToScan = array(realpath('/var/www/axim.caspan.com/Software/'));
$DirectoriesScanned = array();
while (count($DirectoriesToScan) > 0) {
foreach ($DirectoriesToScan as $DirectoryKey => $startingdir) {
if ($dir = @opendir($startingdir)) {
while (($file = readdir($dir)) !== false) {
if (($file != '.') && ($file != '..')) {
$RealPathName = realpath($startingdir.'/'.$file);
if (is_dir($RealPathName)) {
if (!in_array($RealPathName, $DirectoriesScanned) && !in_array($RealPathName,
$DirectoriesToScan)) {
$DirectoriesToScan[] = $RealPathName;
$DirList[] = $RealPathName;
}
}
}
}
closedir($dir);
}
$DirectoriesScanned[] = $startingdir;
unset($DirectoriesToScan[$DirectoryKey]);
}
}
$DirList = array_unique($DirList);
sort($DirList);
foreach ($DirList as $dirname) {
echo $dirname."<br>";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37767
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37767&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37767&report=yes
Search -- http://master.php.net/manage/user-notes.php