Destramic Posted April 17, 2011 Share Posted April 17, 2011 hey guys im tyring to read my directory (whole of the web server)...i want to be able to put the file name and root into an array...im just wanting to know whats the best function i need to do this please?...thank you Link to comment https://forums.phpfreaks.com/topic/233951-reading-file-directory/ Share on other sites More sharing options...
spiderwell Posted April 17, 2011 Share Posted April 17, 2011 can you give an example of how it will look once in the array, what different values you need. are you just after a full path split at each level into the array. or are you after a listing of all folders and subfolders within your website? Link to comment https://forums.phpfreaks.com/topic/233951-reading-file-directory/#findComment-1202532 Share on other sites More sharing options...
Destramic Posted April 17, 2011 Author Share Posted April 17, 2011 ok this is what i have at the moment. <?php if ($handle = opendir('../')) { while (false !== ($file = readdir($handle))) { echo $file . "<br />"; } closedir($handle); } ?> now in this loop it shows folders...but what i want to do is if the $file is a folder then open that up and read directory Link to comment https://forums.phpfreaks.com/topic/233951-reading-file-directory/#findComment-1202544 Share on other sites More sharing options...
spiderwell Posted April 17, 2011 Share Posted April 17, 2011 you want to build a recursive function, bit like this one here Link to comment https://forums.phpfreaks.com/topic/233951-reading-file-directory/#findComment-1202573 Share on other sites More sharing options...
Destramic Posted April 18, 2011 Author Share Posted April 18, 2011 exactly what i wanted...thanks alot Link to comment https://forums.phpfreaks.com/topic/233951-reading-file-directory/#findComment-1203058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.