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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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