Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Regex specify multiple paths using glob()

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.

like image 784
Norse Avatar asked May 19 '12 09:05

Norse


1 Answers

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.


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

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


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

like image 61
Pascal MARTIN Avatar answered Oct 21 '22 15:10

Pascal MARTIN