PHP Regex specify multiple paths using glob()

前端 未结 2 1570
栀梦
栀梦 2021-01-18 00:52
glob(\"aaafolder/*php\")
glob(\"bbbfolder/*php\")
glob(\"cccfolder/*php\")

Is it possible to simplify this?

glob(\"(?=aaafolder/*p         


        
相关标签:
2条回答
  • 2021-01-18 01:31

    As the PHP manual said, its the GLOB_BRACE flag.

    glob("{aaafolder/*php,bbbfolder/*php,cccfolder/*php}", GLOB_BRACE)
    
    0 讨论(0)
  • 2021-01-18 01:39

    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 ;-)

    0 讨论(0)
提交回复
热议问题