ifubad Posted August 28, 2008 Share Posted August 28, 2008 Using the function readdir to get a list of files, and only if the file is a jpg, then those files will get stored into the array. Would it be correct to use regex to check the extension? Link to comment https://forums.phpfreaks.com/topic/121651-solved-using-readir-and-only-store-jpg-in-array/ Share on other sites More sharing options...
Psycho Posted August 28, 2008 Share Posted August 28, 2008 You could, but it would probably be easier to just check the last 4 characters to see if they equal '.jpg' if (str_to_lower(substr($filename, -4))=='.jpg') { echo "It's a jpeg!"; } else { echo "It's NOT a jpeg."; } Link to comment https://forums.phpfreaks.com/topic/121651-solved-using-readir-and-only-store-jpg-in-array/#findComment-627582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.