note 60374 added to class.dir
| From: | AntonBacker at osu1 dot php dot net | Date: | Thu, 05 Jan 2006 03:24:35 +0000 |
| Subject: | note 60374 added to class.dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101238@lists.php.net to get a copy of this message | ||
i've modified the script below to get the leaf folders of any directory (folders with no
subfolders).
note: this does not return the folder passed in as a parameter, even if it has no subfolders.
<?php
function get_leaf_dirs($dir) {
$array = array();
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if($entry!='.' && $entry!='..') {
$entry = $dir.'/'.$entry;
if(is_dir($entry)) {
$subdirs = get_leaf_dirs($entry);
if ($subdirs)
$array = array_merge($array, $subdirs);
else
$array[] = $entry;
}
}
}
$d->close();
return $array;
}
?>
----
Manual Page -- http://www.php.net/manual/en/class.dir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60374
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60374&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60374&report=yes
Search -- http://master.php.net/manage/user-notes.php