public function directories($directoryName)
    {
        if (!$this->isDir($directoryName)) {
            throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($directoryName,
                RecursiveDirectoryIterator::CURRENT_AS_FILEINFO)
        );

        $directories = [];

        foreach($iterator as $file) {
            if($file->isDir()) {
                if( !(substr($file,-2) === '..')) {
                    $directories[] = trim($file,'.');
                }
            }
        }

        array_shift($directories);

        return $directories;
    }
public function directories($directoryName)
    {
        if (!$this->isDir($directoryName)) {
            throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($directoryName,
                RecursiveDirectoryIterator::CURRENT_AS_FILEINFO)
        );

        $directories = [];

        foreach($iterator as $file) {
            if($file->isDir()) {
                if( !(substr($file,-2) === '..')) {
                    $directories[] = trim($file,'.');
                }
            }
        }

        array_shift($directories);

        return $directories;
    }
public function directories ( $ directoryName ) { if ( ! $ this -> isDir ( $ directoryName ) ) { throw new FileNotFoundException ( 'Directory not found in the path [ ' . $ directoryName . ' ].' ) ; } $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directoryName , RecursiveDirectoryIterator :: CURRENT_AS_FILEINFO ) ) ; $ directories = [ ] ; foreach ( $ iterator as $ file ) { if ( $ file -> isDir ( ) ) { if ( ! ( substr ( $ file , - 2 ) === '..' ) ) { $ directories [ ] = trim ( $ file , '.' ) ; } } } array_shift ( $ directories ) ; return $ directories ; }
To get all directories in a directory

@param string $directoryName

@return array
@throws FileNotFoundException
To get all directories in a directory