PHP获取给定目录的所有子目录 [英] PHP Get all subdirectories of a given directory
本文介绍了PHP获取给定目录的所有子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得给定目录的所有子目录,而不包含。
(当前目录)或 ..
(父目录)
,然后在函数中使用每个目录?
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?
推荐答案
可以使用 glob()与 GLOB_ONLYDIR
选项
或
$dirs = array_filter(glob('*'), 'is_dir');
print_r( $dirs);
这篇关于PHP获取给定目录的所有子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文