Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 972
alex Avatar asked Mar 26 '10 01:03

alex


People also ask

Is glob glob case insensitive?

glob() is case sensitive in Linux, but case insensitive in Windows.

What does glob do in PHP?

Definition and Usage The glob() function returns an array of filenames or directories matching a specified pattern.


1 Answers

Glob patterns support character ranges:

glob('my/dir/*.[cC][sS][vV]') 
like image 140
Ignacio Vazquez-Abrams Avatar answered Sep 18 '22 19:09

Ignacio Vazquez-Abrams