baseten baseten - 1 year ago 93
PHP Question

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:


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

Answer Source

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

I made a test and it works for me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download