note 46981 deleted from function.opendir by betz
| From: | betz@php.net | Date: | Fri, 29 Oct 2004 10:20:13 +0000 |
| Subject: | note 46981 deleted from function.opendir by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79308@lists.php.net to get a copy of this message | ||
Note Submitter: daniel at recharged dot info
----
A nice, quick, recursive function to list a dir and all subdirs:
<?php
$dir = '.';
function listdir($path)
{
$handle = opendir($path);
while ($file = readdir($handle)) {
if (($file != '.') AND ($file != '..')) {
if (is_dir($path.'/'.$file)) listdir($path.'/'.$file);
else echo "<a
href=\"$path/$file\">$path/$file</a><br>";
}
}
}
listdir($dir);
?>
----
Reason: bad code