note 66462 added to function.readdir
| From: | harman_tom at hotmail dot com | Date: | Tue, 23 May 2006 13:20:34 +0000 |
| Subject: | note 66462 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111859@lists.php.net to get a copy of this message | ||
I am new to PHP and can't seem to figure out how to only show certain file types in the
following script.
<code>
<?php
$DirectoriesToScan = array(realpath('.'));
$DirectoriesScanned = array();
while (count($DirectoriesToScan) > 0) {
foreach ($DirectoriesToScan as $DirectoryKey => $startingdir) {
if ($dir = @opendir($startingdir)) {
while (($file = readdir($dir)) !== false) {
if (($file != '.') && ($file != '..')) {
$RealPathName = $file;
if (is_dir($RealPathName)) {
if (!in_array($RealPathName, $DirectoriesScanned) && !in_array($RealPathName,
$DirectoriesToScan)) {
$DirectoriesToScan[] = $RealPathName;
}
} elseif (is_file($RealPathName)) {
$FilesInDir[] = $RealPathName;
}
}
}
closedir($dir);
}
$DirectoriesScanned[] = $startingdir;
unset($DirectoriesToScan[$DirectoryKey]);
}
}
$FilesInDir = array_unique($FilesInDir);
sort($FilesInDir);
foreach ($FilesInDir as $filename) {
echo ("<a href=$filename>$filename</a><br>");
}
?>
</code>
----
Server IP: 212.199.163.191
Probable Submitter: 82.195.99.13
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/note/edit/66462
Del: integrated -- http://master.php.net/note/delete/66462/integrated
Del: useless -- http://master.php.net/note/delete/66462/useless
Del: bad code -- http://master.php.net/note/delete/66462/bad+code
Del: spam -- http://master.php.net/note/delete/66462/spam
Del: non-english -- http://master.php.net/note/delete/66462/non-english
Del: in docs -- http://master.php.net/note/delete/66462/in+docs
Del: other reasons-- http://master.php.net/note/delete/66462
Reject -- http://master.php.net/note/reject/66462
Search -- http://master.php.net/manage/user-notes.php