note 52864 deleted from function.readdir by tularis
| From: | tularis@php.net | Date: | Sun, 13 May 2007 19:03:20 +0000 |
| Subject: | note 52864 deleted from function.readdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126529@lists.php.net to get a copy of this message | ||
Note Submitter: matthew dot panetta at gmail dot com
----
Here is a simple directory walker class that does not use recursion.
<?
class DirWalker {
function go ($dir) {
$dirList[] = $dir;
while ( ($currDir = array_pop($dirList)) !== NULL ) {
$dir = opendir($currDir);
while((false!==($file=readdir($dir)))) {
if($file =="." || $file == "..") {
continue;
}
$fullName = $currDir . DIRECTORY_SEPARATOR . $file;
if ( is_dir ( $fullName ) ) {
array_push ( $dirList, $fullName );
continue;
}
$this->processFile ($file, $currDir);
}
closedir($dir);
}
}
function processFile ( $file, $dir ) {
print ("DirWalker::processFile => $file, $dir\n");
}
}
?>