Reputation: 361
I'm trying to count all files (all of which are images) in a folder for an image gallery. In this folder I have photos named 1.jpg, 2.jpg, 3.jpg, and so on. However, there are a few photos in this folder that have a letter in the filename (example: filename is 12b.jpg or 12c.jpg) in the same folder, but I don't want them to be counted as a file/image in my counting script.
Can I use PHP's glob function to exclude filenames containing a letter, or perhaps include only filenames containing purely numbers?
I think I can use REGEX to do this, but I'm not familiar enough with it to know how to exclude anything other than specific characters, rather than restricting a type of character (ie letters).
Current Code is:
// Get Exterior Image Count
$exteriorImgDirectory = "images/exterior-photos/";
if (glob($exteriorImgDirectory . "*.jpg") != false)
{$exteriorCount = count(glob($exteriorImgDirectory . "*.*"));}
Upvotes: 0
Views: 800