This function will do it:
function getFilesByType($dir, $type = 'dir')
{
if (($dh = opendir($dir)) === false) {
trigger_error('opendir', E_USER_ERROR);
} else {
if ($dir[strlen($dir) -1] == DIRECTORY_SEPARATOR) {
$sep = '';
} else {
$sep = DIRECTORY_SEPARATOR;
}
$list = array();
while (($ent = readdir($dh)) !== false) {
if ($ent == '.' || $ent == '..') continue;
if (filetype("$dir$sep$ent") == $type) {
$list[] = "$dir$sep$ent";
}
}
closedir($dh);
return $list;
}
return false;
}
On Feb 10, 8:00 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.comwrote:
Hi,
I'm using PHP 4.4.4 with Apache 2 on Fedora Core 6 Linux. Given a
directory, how would I get all sub-directories? I found "scandir" but
that only applies for PHP 5 and I think it returns both files and
folders, whereas I only want the folders.
Thanks for any help, - Dave