Search code examples
phpglob

php glob pattern match for arbitray number of digits


Is it possible to match an arbitrary number of digits with the php glob function? I'm trying to match file names for image thumbnails that end with dimensions ranging from two to four digits.

I know I can supply a digit range, but this only matches a single character:

glob("thumbname-[0-9]-[0-9].jpg")

This will match thumbname-1-1.jpg but not thumbname-10-10.jpg, etc.


Solution

  • Try using: glob("thumbname-[0-9]*-[0-9]*.jpg")

    I made a test and it works for me.