简体   繁体   English

PHP Glob函数可匹配目录,但不能匹配文件

[英]PHP glob function to match directories but not files

I am trying to use the PHP function glob() to match directories, not files . 我正在尝试使用PHP函数glob()来匹配目录,而不是文件 I can get it to match all folders using glob('*') , but that matches files also. 我可以使用glob('*')来匹配所有文件夹,但是也可以匹配文件。 I can match all files using glob(*.*) , but that's not what I want. 我可以使用glob(*.*)匹配所有文件,但这不是我想要的。

Is there a way to subtract perameters from the glob() matching system, or should I use preg_match() to limit the results? 有没有办法从glob()匹配系统中减去性能参数,还是应该使用preg_match()来限制结果?

According to the manual : 根据手册

GLOB_ONLYDIR - Return only directory entries which match the pattern GLOB_ONLYDIR-仅返回与模式匹配的目录条目

So that would be: 因此将是:

glob('*', GLOB_ONLYDIR)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM