PHP Regex Defines Multiple Paths Using glob ()

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

Can this be simplified?

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

The above returns nothing.

+7
source share
2 answers

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


I quote the example that @Ultimater gives there:

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


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

+15
source

As a PHP manual , its flag is GLOB_BRACE .

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

All Articles