Jump to content

Directory structure


george_king

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/67922-directory-structure/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/67922-directory-structure/#findComment-341422
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.