Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 PHP 函数glob()来匹配目录,而不是文件。我可以让它匹配使用的所有文件夹glob('*'),但它也匹配文件。我可以使用 匹配所有文件glob(*.*),但这不是我想要的。
glob()
glob('*')
glob(*.*)
有没有办法从匹配系统中减去参数,或者我应该用它来限制结果?glob()preg_match()
preg_match()
根据手册:
GLOB_ONLYDIR - 仅返回与模式匹配的目录条目
所以那将是:
glob('*', GLOB_ONLYDIR)