public function expandDirectories($baseDir) {
        $directories = array();
        foreach (scandir($baseDir) as $file) {
            if ($file == '.' || $file == '..')
                continue;
            $dir = $baseDir . DS . $file;
            if (is_dir($dir)) {
                $directories [] = $dir;
                $directories = array_merge($directories, $this->expandDirectories($dir));
            }
        }
        return $directories;
    }
public function expandDirectories($baseDir) {
        $directories = array();
        foreach (scandir($baseDir) as $file) {
            if ($file == '.' || $file == '..')
                continue;
            $dir = $baseDir . DS . $file;
            if (is_dir($dir)) {
                $directories [] = $dir;
                $directories = array_merge($directories, $this->expandDirectories($dir));
            }
        }
        return $directories;
    }
public function expandDirectories ( $ baseDir ) { $ directories = array ( ) ; foreach ( scandir ( $ baseDir ) as $ file ) { if ( $ file == '.' || $ file == '..' ) continue ; $ dir = $ baseDir . DS . $ file ; if ( is_dir ( $ dir ) ) { $ directories [ ] = $ dir ; $ directories = array_merge ( $ directories , $ this -> expandDirectories ( $ dir ) ) ; } } return $ directories ; }
Recursive function that returns all directories inside a base directory.

@param string $baseDir
@return array
Recursive function that returns all directories inside a base directory .