Re: Getting the filenames from a folder




juglesh wrote:
> Chung Leong wrote:
> > I usually use glob() 'cause I'm lazy.
> >
> > http://fi.php.net/glob/
>
> nice, i never saw that. I assume you could go *.*, can you give it
> multiple matches, like *.jpg, *.gif ?

Yes, if you pass the GLOB_BRACE flag.

Example:

$images = glob("*.{jpeg,jpg,gif,png}", GLOB_BRACE);

You can also character class matching with glob():

$images = glob("[ab]*.gif"); // gif files starting with letter a or b

And wildcards work for sub-folder as well:

$images = glob("*/*.gif"); // gif files in all sub-folders

A real time-saver. One downside though is that the function is broken
in some versions on Win32.

.