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. 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 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. 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
Archived
This topic is now archived and is closed to further replies.