Can PHP's glob() be made to find files in a case insensitive manner?
问题 I want all CSV files in a directory, so I use glob('my/dir/*.CSV') This however doesn't find files with a lowercase CSV extension. I could use glob('my/dir/*.{CSV,csv}', GLOB_BRACE); But is there a way to allow all mixed case versions? Or is this just a limitation of glob() ? 回答1: Glob patterns support character ranges: glob('my/dir/*.[cC][sS][vV]') 回答2: You could do this $files = glob('my/dir/*'); $csvFiles = preg_grep('/\.csv$/i', $files); 回答3: glob('my/dir/*.[cC][sS][vV]') should do it.