Possible Duplicate:
PHP - Iterate through folders and display HTML contents
Using PHP, I'm trying to create a script that will navigate to the root directory of a website, and from there, using scandir()
or glob()
(those being the only directory scanning functions I've learned), I would use a recursive method to navigate through all the items in the root directory, then re-calling itself when encountering an entry that tested to be a directory, through is_dir($fileName)
.
Here's where I'm encountering problems - when I reach an entry that is a directory, it correctly navigates the if statement correctly to the commands for directories, but when calling itself, I don't seem to be able to get the glob()
directory right, since every time I call it, the page ceases to load anything more. I'm trying to figure out, from the relative URL-based nature of scanning directories how I would reference it. I set a variable $ROOT_DIR
, which is the root directory relative to the directory in which the php page is located in (in this case, $ROOT_DIR="../../"
), and then I'd think logically, I'd call scanAllFiles [my sitemap method] with $ROOT_DIR . $fileName, where that's the string of the directory found, after removing the leading "../../"
from the string. After trying this, it doesn't work.
Should I be using a different directory-traversing method to do this, or am I formatting the method call incorrectly?