PHP: case insensitive glob for multiple extentions

hankknight
hankknight used Ask the Experts™
on
Using the PHP function glob, how can I get all jpg, gif and png images from a directory regardless of the case?

This does NOT work:

foreach (glob("dirname/*.{[jJ][pP][gG],[pP][nN][gG],[gG][iI][fF]}", GLOB_BRACE) as $filename) {

}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
Why does glob() matter in this question?  Are you open to other solutions that will get you an array of the file names?
I agree with Ray. I would use scandir

http://www.php.net/scandir

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial