Get Sub Directories

Danny Nunez edited this page Jun 8, 2013 · 2 revisions

getSubDirectories($path)

This method will return all subdirectories of a given path.

    public function getSubDirectories($path) {
        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $file) {
            if ($file->isDir()) {
                $subDirectories[] = $file->getRealpath();
            }
        }
        if (empty($subDirectories)) {
            return null;
        }
        return $subDirectories;
    }

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.