PHP Regex使用glob()指定多条路径

时间:2022-09-01 23:18:16
glob("aaafolder/*php")
glob("bbbfolder/*php")
glob("cccfolder/*php")

Is it possible to simplify this?

可以化简一下吗?

glob("(?=aaafolder/*php)(?=bbbfolder/*php)(?=cccfolder/*php)")

The above returns nothing.

上面的回报。

2 个解决方案

#1


15  

This note on the manual page of glob() seems to answer your question, saying that glob is not limited to a single directory : using GLOB_BRACE, you can specify several directories.

glob()的手册页上的说明似乎回答了您的问题,它说glob并不局限于一个目录:使用glob_span,您可以指定几个目录。


I'm quoting the example that @Ultimater gives there :

我引用@Ultimater的例子:

$results=glob("{includes/*.php,core/*.php}",GLOB_BRACE);


User-notes on the manual pages often contain useful informations and examples ;-)

手册页上的用户说明通常包含有用的信息和示例;-)

#2


3  

As the PHP manual said, its the GLOB_BRACE flag.

正如PHP手册所说,它是glob_括弧标志。

glob("{aaafolder/*php,bbbfolder/*php,cccfolder/*php}", GLOB_BRACE)

#1


15  

This note on the manual page of glob() seems to answer your question, saying that glob is not limited to a single directory : using GLOB_BRACE, you can specify several directories.

glob()的手册页上的说明似乎回答了您的问题,它说glob并不局限于一个目录:使用glob_span,您可以指定几个目录。


I'm quoting the example that @Ultimater gives there :

我引用@Ultimater的例子:

$results=glob("{includes/*.php,core/*.php}",GLOB_BRACE);


User-notes on the manual pages often contain useful informations and examples ;-)

手册页上的用户说明通常包含有用的信息和示例;-)

#2


3  

As the PHP manual said, its the GLOB_BRACE flag.

正如PHP手册所说,它是glob_括弧标志。

glob("{aaafolder/*php,bbbfolder/*php,cccfolder/*php}", GLOB_BRACE)