OK below is this little filesystem crawler for use on Linux. This thing is fast, real fast, mainly because it is so low level at the moment. Now I am faced with a problem and I need some thoughts. What I want to end up with is a sorted multidimensional array where $array[] containts the root folders and files, and each level down contains the subs, for example:
/root
app1/
images/
image1.gif
includes/
config.inc.php
app2/
app3/
$array['app1']['images'][0] would be image1.gif.
$array['app1']['includes'][0] would be config.gif.
Here is a rough idea INCOMPLETE EXAMPLE of what my class looks like:
class spider
{
var $name;
var $folders;
var $files;
function spider($dir){
global $init;
global $count;
$rx = @opendir($dir);
$part = str_replace($init,'',realpath($dir));
$this->name=$part;
$depth = split('/',$part);
$depth = count($depth);
while($file = @readdir($rx)){
if($file != '.' and $file!='..'){
#$buff = ftp_mdtm($ftp, $dir.'/'.$file);
if(is_dir($dir.'/'.$file)){
$this->folders[]=$file
$thi = new spider($dir.'/'.$file);
$thi = null;
} else {
$count++;
$this->files[] = $file;
}
}
}
}
}
?>
Now the class does a great job of gathering the layout , my questions is pretty much can anyone help me improve / resolve my problem of getting the sorted multidimensional array of the layout?
I have soo much giong on I can't work this out.