Try something like this:
<?php
function list_all_dirs($dir) {
// Should we add a trailing slash?
$dir .= ( substr($dir, -1) != "/" ) ? "/" : "";
// Open the dir:
$handle = opendir($dir);
// The array that will store the dirs:
$folders = array();
// Read through the dir:
while(($item = readdir($handle)) !== FALSE) {
if(( $item != "." ) && ( $item != ".." ) && is_dir($dir.$item)) {
$folders[] = $item;
}
}
// Create the list and return it:
return implode("<br/>\n", $folders);
}
# Example:
$folders = list_all_dirs(".");
echo $folders;
?>