/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Find Files in Directory with Pattern Matching

Hi,

I’ve beating my head against a wall all day.

Been trying to create a function to retrieve the number of files from a directory that match a pattern. I though it was fairly simple…. ?

PATTERN
“images/02-??23-1234-0?.jpg”
?? can be any of 01,05,28,18,66
? can be 1 to 5

GLOB won’t do, I’ve tried REGEX, but didn’t seem to work. Also tried open-dir(), but by then my head was about to explode.

Anyone please….

Thanks,

Barton.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 16.2009 — How about:
[code=php]
$files = glob("images/02-{01,05,28,18,66}23-1234-0{1,2,3,4,5}.jpg", GLOB_BRACE);
[/code]

?
Copy linkTweet thisAlerts:
@Barton68authorNov 17.2009 — So simple, I just do not understand why I failed to get it working.

Many, many thanks,

Barton.
×

Success!

Help @Barton68 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...