Create a select dropdown from file tree of images & sub directories using PHP?

You need a loop inside a loop. Assuming only 2 levels of directories, in your while check if $file is a subdirectory with is_dir() and if yes do a readdir() on that too to get its options built.

You need a loop inside a loop. Assuming only 2 levels of directories, in your while check if $file is a subdirectory with is_dir(), and if yes do a readdir() on that too to get its options built. Then, you can distinguish the subdirectories by optgroup in your element.

If you need multiple varying levels of subdirectories you'll need a recursive function to take care of it. The one shown here is a good starting point.

If its more then a single level, might as well code for the general case and make it recursive. – Chris Oct 11 '10 at 20:14 @Chris, absolutely, I'm just trying to have Kim ease into the problem with the specific use case first. I've provided the link with ready code for the general case when she feels ready to tackle that.

– Fanis Oct 11 '10 at 21:22 Thanks guys, yeah, I'll try the easiest method first and then take a look at the general case, too :) – Kim Oct 12 '10 at 7:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions