可以使PHP的glob()以不区分大小写的方式查找文件吗?
问题描述:
我希望所有CSV文件都在目录中,所以我使用
I want all CSV files in a directory, so I use
glob('my/dir/*.CSV')
但是,找不到带有小写CSV扩展名的文件.
This however doesn't find files with a lowercase CSV extension.
我可以使用
glob('my/dir/*.{CSV,csv}', GLOB_BRACE);
但是有没有办法允许所有大小写混合的版本?还是这只是glob()
的限制?
But is there a way to allow all mixed case versions? Or is this just a limitation of glob()
?
答
全局模式支持字符范围:
Glob patterns support character ranges:
glob('my/dir/*.[cC][sS][vV]')