pooker Posted June 26, 2008 Share Posted June 26, 2008 I am having problems with this script, I want it to open th directory, then read it and return only the the name and print it in a dropdown menu if it is a directory. Code <?php $dir = opendir('./mangareader/'); while($folder = readdir($dir) ){ if (is_dir($folder)) { ?> <option value='1'><? echo $folder ?></option> <? } } closedir($dir); ?> the dropdown menu works and everything this is just the bare code for how i did the script Link to comment https://forums.phpfreaks.com/topic/112003-help-with-readdir/ Share on other sites More sharing options...
ratcateme Posted June 26, 2008 Share Posted June 26, 2008 so what exactly is wrong?? Scott. Link to comment https://forums.phpfreaks.com/topic/112003-help-with-readdir/#findComment-574914 Share on other sites More sharing options...
pooker Posted June 26, 2008 Author Share Posted June 26, 2008 ok I got it to work, but when I ask it to just read the directorys it just outputs periods Anyreason why? It out puts lik this in menu . .. Which there is two directories but it does not list there names Link to comment https://forums.phpfreaks.com/topic/112003-help-with-readdir/#findComment-574915 Share on other sites More sharing options...
ratcateme Posted June 26, 2008 Share Posted June 26, 2008 because when php views a directory it finds: "." the current dir ".." the previous dir to remove these change the if to if (is_dir($folder) && $folder != ".." && $folder != ".") { Scott. Link to comment https://forums.phpfreaks.com/topic/112003-help-with-readdir/#findComment-574921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.