PHP: case insensitive glob for multiple extentions

hankknight used Ask the Experts™
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

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
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

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