Hi all,
This piece of code should show all files - and the path to them - in a folder and it subfolders. It works quiet ok with php 4.1.2, but on php 4.0.0 (where it must run) i get a "Warning: Cannot compare arrays or objects in line x" and no output.
Here is the relevant code, does anyone know what could be wrong?
$basedir = "/xyz/"; //example: "/var/www/path/to/your/dir/"
$baseurl = "http://xyz/"; //example: "/http://your.domain.com/your/dir/
function getDirList ($basedir,$relativ_dir){
GLOBAL $baseurl,$file_array;
$d = dir($basedir);
while($entry = $d->read()) {
if ($entry != "." && $entry != "..") {
if (is_dir($basedir."/".$entry)) {
getDirList($basedir."/".$entry,$relativ_dir.$entry."/");
} else {
$mdate = filemtime($basedir."/".$entry);
$file_array[] = array("mdate"=>$mdate,"path"=>$baseurl.$relativ_dir.$entry,"entry"=>$entry);
}
}
}
$d->close();
return $file_array;
}
$file_array = getDirList($basedir,"");
rsort($file_array);
foreach ($file_array as $index => $array_of_files){
echo "<li>".date(r,$array_of_files["mdate"]).": <a href=\"".$array_of_files["path"]."\" target=\"_self\" class=kleinCopy>".$array_of_files["entry"]."</a>";
}
Put in some PHP tags to make the thing readable; Weedpacket