Get all directories in PHP

I think this may be the fastest way to get a list of all the directories in a given folder/directory using PHP.

$directories = array_filter(glob(‘*’), ‘is_dir’);

..and of course you can also add a path to it if you need to:

$directories = array_filter(glob($myPath.‘*’), ‘is_dir’);

Share This Article

Related Posts

Comments

  1. Mike Collier April 29, 2011

    just brilliant – took some finding on the web but works just fine for what i want for an automatic picture gallery where each event has its own folder of pics

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional

Latest Domains

1. teledyne.com
(6 hours ago)
2. ngtechonology.com
(6 hours ago)
3. nonude.in
(7 hours ago)
4. spicyhunt.com
(13 hours ago)
5. whpromotions.co.uk
(16 hours ago)
6. seslihome.com
(17 hours ago)
7. sesliislam.com
(20 hours ago)
8. woopra.com
(1 day ago)
9. wapdam.com
(1 day ago)
10. 193.105.134.194
(1 day ago)

Services

PHP MySQL Apache Flash Air Java C++ Python