HCProfessionals Posted October 2, 2011 Share Posted October 2, 2011 I'm trying to echo the directory and sub directory only. I am not looking to show the files contained - only folders. Quote Link to comment https://forums.phpfreaks.com/topic/248288-echo-directory-and-sub-directorys/ Share on other sites More sharing options...
mikesta707 Posted October 2, 2011 Share Posted October 2, 2011 try using the glob() function with the GLOB_ONLYDIR flag. see the manual entry for more information and code examples: http://php.net/manual/en/function.glob.php Quote Link to comment https://forums.phpfreaks.com/topic/248288-echo-directory-and-sub-directorys/#findComment-1275010 Share on other sites More sharing options...
HCProfessionals Posted October 2, 2011 Author Share Posted October 2, 2011 I've only gotten as far as showing the folders in the current working directory. I can't get them to show the sub-folders of each folder. Quote Link to comment https://forums.phpfreaks.com/topic/248288-echo-directory-and-sub-directorys/#findComment-1275013 Share on other sites More sharing options...
mikesta707 Posted October 2, 2011 Share Posted October 2, 2011 if you want to show sub folders you will have to go through all your directories retrieved from the original glob call, and recursively or iteratively call glob on each of those directories. I would suggest doing this recursively myself. If I remember correctly, in the comments section of the glob manual entry some people have already found the solution to this problem and posted the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/248288-echo-directory-and-sub-directorys/#findComment-1275041 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.