Can PHP's glob() be made to find files in a case insensitive manner?

alex picture alex · Mar 26, 2010 · Viewed 21.6k times · Source

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() ?

Answer

Ignacio Vazquez-Abrams picture Ignacio Vazquez-Abrams · Mar 26, 2010

Glob patterns support character ranges:

glob('my/dir/*.[cC][sS][vV]')