简体   繁体   中英

Using two patterns in glob() PHP?

I have a list of files, with different items separated by a hyphen, followed by ".txt". EX: Dog_Cat.txt could be a file, but so could Cat_Dog.txt, and Cat.txt, Dog.txt are also valid. Is there a way I could use glob to return all files with let's say, "Dog_xxx.txt" or "xxx_Dog.txt" using the glob() function? Or is only one pattern legal? Thanks!

您可以使用花括号来组合多个模式。

glob('{Dog_*,*_Dog}.txt', GLOB_BRACE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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