This is only one function that it should do the same.
It pass all files to an array.Then all folders of a directory to an array.
It then reads the arrays, outputs the elements of them and runs the function for every element of folders array.
The problem is that it fails to change dirs succesfuly.It's something on the chdir($startdir).
Any ideas anyone?
I comment the lines for the real outputs and I output the currentdir and the startdir.
<?php
function filelist ($currentdir, $startdir=NULL, $Cfiles=NULL,$files=Array()) {
global $startdir;
if (!$startdir) {
$startdir = $currentdir;
}
echo"<u>$currentdir</u>";
chdir ($currentdir);
$d = opendir (".");
while ($file = readdir ($d)) {
if ($file != ".." && $file != ".") {
if (!is_dir ($file)) {
array_push($files,"$file");
$folders=Array();
}
}
}
closedir ($d);
$dr = opendir (".");
while ($folder = readdir ($dr)) {
if ($folder != ".." && $folder != ".") {
if (is_dir ($folder)) {
array_push($folders,"$startdir/$folder");
}
}
}
closedir ($dr);
echo"==<b>$startdir</b><br>";
chdir($startdir);
$Cfiles=count($files);
$Cfolders=count($folders);
for ($i=0;$i<$Cfiles;$i++){
// echo"$files[$i]<br>";
}
for ($i=0;$i<$Cfolders;$i++){
// echo"<b>$folders[$i]</b><br>";
filelist($folders[$i]);
}
}
$t=filelist(".");
?>
Thanks everyone...