note 15091 rejected from function.readdir by sander
| From: | sander@php.net | Date: | Sat, 06 Apr 2002 19:16:04 +0000 |
| Subject: | note 15091 rejected from function.readdir by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-28754@lists.php.net to get a copy of this message | ||
If you want to avoid using arrays, and still print out files in a tree recursively use something
like this:
<?php
function echo_dir($where) {
$handle = opendir('.');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
chdir($file);
echo_dir($file);
chdir("../");
} else {
if ($where != "") {
echo "$where/$file<br>";
} else {
echo "$file<br>";
}
}
}
}
closedir($handle);
}
echo_dir("");
?>