[英]Using two patterns in glob() PHP?
I have a list of files, with different items separated by a hyphen, followed by ".txt". 我有一个文件列表,不同项目之间用连字符隔开,后跟“ .txt”。 EX: Dog_Cat.txt could be a file, but so could Cat_Dog.txt, and Cat.txt, Dog.txt are also valid.
例如:Dog_Cat.txt可以是一个文件,但是Cat_Dog.txt和Cat.txt,Dog.txt也是有效的。 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?
有没有一种方法可以使用glob()函数使用glob返回所有文件,例如“ Dog_xxx.txt”或“ xxx_Dog.txt”? Or is only one pattern legal?
还是只有一种模式合法? Thanks!
谢谢!
您可以使用花括号来组合多个模式。
glob('{Dog_*,*_Dog}.txt', GLOB_BRACE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.