aebstract Posted May 12, 2010 Share Posted May 12, 2010 $dir = 'gallery/'; $categories = scandir($dir); $categories = array_slice($categories, 2); The reason I am slicing is because it returns 2 extra values "." and ".." that I do not need. When I run this, I'm getting back folders and files, obviously. How can I get a list of only the directories? I'm going to need to be able to do the same and get only files as well. Working with nothing but .jpg and folders here. Quote Link to comment https://forums.phpfreaks.com/topic/201526-get-a-list-of-all-directories/ Share on other sites More sharing options...
kenrbnsn Posted May 12, 2010 Share Posted May 12, 2010 Use the glob function: <?php $dir_list = glob('*',GLOB_ONLYDIR); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/201526-get-a-list-of-all-directories/#findComment-1057274 Share on other sites More sharing options...
aebstract Posted May 12, 2010 Author Share Posted May 12, 2010 Hey thanks I was able to get both the directories and list of files in them separate with this. Quote Link to comment https://forums.phpfreaks.com/topic/201526-get-a-list-of-all-directories/#findComment-1057282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.