alconebay Posted November 8, 2008 Share Posted November 8, 2008 I currently am using $images = glob("" . $directory . "*.jpg"); to get the filename of all the jpg images in my directory. However, some of the images are .JPG instead of .jpg. How can I modify the code to get it to read both .jpg and .JPG files? Link to comment https://forums.phpfreaks.com/topic/131886-solved-glob-for-multiple-file-types/ Share on other sites More sharing options...
Jeremysr Posted November 8, 2008 Share Posted November 8, 2008 Apparently there is no case-insensitive flag for glob() so what I would do is this: $images = array_merge(glob($directory . "*.jpg"), glob($directory . "*.JPG")); Link to comment https://forums.phpfreaks.com/topic/131886-solved-glob-for-multiple-file-types/#findComment-685156 Share on other sites More sharing options...
alconebay Posted November 8, 2008 Author Share Posted November 8, 2008 That worked great. I just found an example (right before you replied) that also worked: $images = glob("$directory{*.jpg,*.JPG,*.png}", GLOB_BRACE); Link to comment https://forums.phpfreaks.com/topic/131886-solved-glob-for-multiple-file-types/#findComment-685158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.