purencool Posted August 13, 2009 Share Posted August 13, 2009 Hi phpfreaks I am trying to display the contents of a directory and if inside that directory another directory is found it will display that contents as well. My issue is I can the contents of the original directory but when I try and access a directory inside the original I get errors. This is what I have so far. I think I am using the wrong function does any one know? global $PAGES_DIR; //taken from the config.php $dirname = $PAGES_DIR; $dirOne = opendir($dirname ); while (($fileOne = readdir($dirOne)) !== false) { echo "filename: " . $fileOne . "<br />"; if (is_dir ($fileOne)){ $fileOne = $dirTwo; echo $dirTwo."<br>"; $openDirTwo = opendir($dirTwo ); while (($fileTwo = readdir($OpenDirTwo)) !== false) { echo "filename: " . $fileTwo . "<br />"; } closedir($openDirTwo); } } closedir($dirOne); Quote Link to comment https://forums.phpfreaks.com/topic/170030-solved-trying-to-read-a-contents-of-a-dir-inside-a-dir/ Share on other sites More sharing options...
.josh Posted August 13, 2009 Share Posted August 13, 2009 read the user notes in readdir or scandir there are several user contributed functions that show how to recursively grab files/subdirectories. Quote Link to comment https://forums.phpfreaks.com/topic/170030-solved-trying-to-read-a-contents-of-a-dir-inside-a-dir/#findComment-896963 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.