hello all.
i am trying to load all directory names in
my site into a single array. this means
sub-directories and so on.
i want to do this, for a directory validation
check, so that users cannot enter a non-valid
directory name.
if i have the array, i can check the entered
value against the array containing every
directory name in my site.
now, i can opendir and readdir, and such, but
i am having difficulty with recursive
functions and reading results into the master
array.
i have some example code that i am trying to
work from, but i am having no luck. maybe
someone can help me on my first post? 😉
code
function allDirectories($directory){
$handle = opendir("$directory");
while ($listing = readdir($handle)){
if ($listing != "." && $listing != ".."){
if (is_dir($listing)){
$directoryArray[] = $listing;
}
for($n = 0; $n < count($directoryArray); $n++){
$directoryPath = $directory."/".$directoryArray[$n];
chdir("$directoryPath");
allDirectories($directoryPath);
chdir("..");
}
}
}
closedir($handle);
for($n=0; $n<count($directoryArray); $n++){
print($directoryArray[$n]);
}
}
allDirectories();
/code
thanks tons,
mikeD