george_king Posted September 4, 2007 Share Posted September 4, 2007 Hi everybody, sorry for my English, but my English is not very well. I want to write you about my problem: I have a directory structure on my server, for example until 7. sublevel of this structure. And i want to write this structure, directories and subdirectories on my website and i don't know write universal algoritmus about for it. I know what functions i have to use, but i don't know how should i write it... Thank you for your advice... Quote Link to comment https://forums.phpfreaks.com/topic/67922-directory-structure/ Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 Do you mean you need to iterate down to the farthest level while grabbing certain (or all) files? One way is to make a recursive function that calls keeps going until it can't find a directory. Something like this: doDir(glob("tier 1/*")); function doDir($files) { foreach($files as $file) { if (is_dir($file)) doDir(glob($file . "/*")); else echo "Doing something with the file<br>"; } } You can change the glob function to fit what kind of files you need. Quote Link to comment https://forums.phpfreaks.com/topic/67922-directory-structure/#findComment-341422 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.