Piccolo
Piccolo

Reputation: 1666

PHP glob function to match directories but not files

I am trying to use the PHP function glob() to match directories, not files. I can get it to match all folders using glob('*'), but that matches files also. I can match all files using glob(*.*), but that's not what I want.

Is there a way to subtract perameters from the glob() matching system, or should I use preg_match() to limit the results?

Upvotes: 0

Views: 366

Answers (1)

jeroen
jeroen

Reputation: 91744

According to the manual:

GLOB_ONLYDIR - Return only directory entries which match the pattern

So that would be:

glob('*', GLOB_ONLYDIR)

Upvotes: 4

Related Questions