Search code examples
phpcase-insensitiveglob

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


Solution

  • Glob patterns support character ranges:

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