timmah1 Posted March 19, 2012 Share Posted March 19, 2012 This script reads a directory, and prints out the name of all directories in the directory that I've chosen This works, but it's only displaying the last 2. Right now, I have 6 directories in the the folder I specified. Can anybody tell me why it does not display all of them? <?php $path = $_SERVER['DOCUMENT_ROOT']."/panel/api/connectors/sample/projects/"; foreach(glob($path . '*', GLOB_ONLYDIR) as $dir) { $dir = basename($dir); echo $dir."<br />"; } ?> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/259267-directory-name/ Share on other sites More sharing options...
creata.physics Posted March 19, 2012 Share Posted March 19, 2012 I've confirmed your code does work by testing it in my xampp 1.7.7 server. It also works on my website host which has more outdated versions of apache and php. I'm guessing the issue is server related but I can't understand why, good luck. Quote Link to comment https://forums.phpfreaks.com/topic/259267-directory-name/#findComment-1329088 Share on other sites More sharing options...
DavidAM Posted March 19, 2012 Share Posted March 19, 2012 1) Check the permissions on the directories you are not getting 2) Show us a list of what you expect and what you get 3) Are any of your directories "hidden" (start with a full-stop ("."))? I'm not sure if glob('*') ignores hidden files or not, seems like I've have trouble with that before. 4) try print_r(glob($path . '*', GLOB_ONLYDIR)) before the foreach loop to see what it reports 5) :'( Quote Link to comment https://forums.phpfreaks.com/topic/259267-directory-name/#findComment-1329151 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.