I wrote a script for reading directory's. The first time I call the readDirectory-Function it detect's every dir and puts them as objects into an array. If I know read-in the files of these directory's it's not detecting dir's anymore...why???
here's the code:
<?php class mapper {
var $name;
var $dirToread;
var $dirArr;
var $handle;
var $file;
var $path;
function mapper($name, $dir_zus) {
$this->dirArr = array();
$this->name = $name;
$this->dirToread=$dir_zus;
}
function readDirectory() {
$this->handle=opendir($this->dirToread);
while ($this->file = readdir($this->handle)) {
if ($this->file == "." || $this->file == "..") { }
elseif (is_dir($this->file)) {
?> <a href ="<?php echo($this->file)?>"><?php echo($this->file);?></a><br><?php
$this->path ="";
$this->path .=$this->dirToread."/".$this->file;
$this->file = new mapper($this->file, $this->path);
$this->dirArr[count($this->dirArr)]=$this->file;
} else {
?> <a href="<?echo($this->file)?>"><?echo($this->file);?></a><br><?
}
}
closedir($this->handle);
if (count($this->dirArr)!=0) {
foreach($this->dirArr as $key=>$val){
$val->readDirectory();
}
}
}
}
?>
<?php
$d = new mapper("root", getcwd());
$d->readDirectory();
echo("DIRECTORY:");
echo(getcwd());
?>