note 60636 added to ref.spl
| From: | ville</.>witt</a>gmail" com | Date: | Thu, 12 Jan 2006 20:37:26 +0000 |
| Subject: | note 60636 added to ref.spl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101654@lists.php.net to get a copy of this message | ||
These to funtions has excatly the same output, the only diff. is in which directory iterator they
use. I hope someone out there can use it:
<?
function listfilesin1 ($dir = ".", $depth=0) {
echo "Dir: ".$dir."<br/>";
foreach(new DirectoryIterator($dir) as $file) {
if (!$file->isDot()) {
if ($file->isDir()) {
$newdir = $file->getPathname();
listfilesin1($newdir, $depth+1);
} else {
echo "($depth)".$file->getPathname() . "<br/>";
}
}
}
}
function listfilesin2 ($dir = ".", $depth=0) {
echo "Dir: ".$dir."<br/>";
foreach(new RecursiveDirectoryIterator($dir) as $file) {
if ($file->hasChildren(false)) {
$newdir = $file->key();
listfilesin2($newdir, $depth+1);
} else {
echo "($depth)".$file->key() . "<br/>";
}
}
}
listfilesin();
?>
----
Manual Page -- http://www.php.net/manual/en/ref.spl.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60636
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60636&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60636&report=yes
Search -- http://master.php.net/manage/user-notes.php