Using PHP5 DirectoryIterator to return all files and folders in a directory
Posted on 2007-12-05
I've looked for answers, but none of those I found had the "simple" answer I'm looking for.
I have a directory on my web server that contains both files and sub-directories with files in them as well.
I would like to build a tree-like structure from the top directory on down and I understand that the DirectoryIterator class will do this, but I just don't understand enough PHP to pull a function together to do this.
I would like to get all files and sub-folders and their contents back in an array if possible so that I can create my own HTML output in a tree-like manner. I would like to get information for the files that are returned, such as type, size, filename as well. Can someone share the code for this using the DirectoryIterator class?