How to get the name of every folder in a directory?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
insight
Forum Commoner
Posts: 52
Joined: Tue Jul 07, 2009 9:12 am

How to get the name of every folder in a directory?

Post by insight »

I was wondering if there is a php code which will get every name of every folder in a directory. For example.

Root directory/public_html/modules and inside modules there will be folders such as News, Menu, Shoutbox, Gallery etc etc. I want to get the name of each folder in the modules directory so I can put it in a select list.

Nevermins the directory I showed you it was just an example, I just need the code and I will modify it myself accordingly.

Cheers
insight
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: How to get the name of every folder in a directory?

Post by jackpf »

You could look into glob() and is_dir().
insight
Forum Commoner
Posts: 52
Joined: Tue Jul 07, 2009 9:12 am

Re: How to get the name of every folder in a directory?

Post by insight »

Just realised, I don't need it :P I have all the folders in a database.

EDIT: But it may help in the future so thanks for your input :)
Post Reply