You are here: Re: Getting the filenames from a folder « PHP Programming Language « IT news, forums, messages
Re: Getting the filenames from a folder

Posted by Chung Leong on 10/31/05 07:14

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация