PHP Get all subdirectories of a given directory

Adrian M. picture Adrian M. · Mar 26, 2010 · Viewed 210.3k times · Source

How can I get all sub-directories of a given directory without files, .(current directory) or ..(parent directory) and then use each directory in a function?

Answer

ghostdog74 picture ghostdog74 · Mar 26, 2010

you can use glob() with GLOB_ONLYDIR option

or

$dirs = array_filter(glob('*'), 'is_dir');
print_r( $dirs);