I want there to be a way to tell which dir the file is in similar to a tree

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27999224.html

there is an array of dirs and array of file

[files] => Array
        (

        )

    [dirs] => Array
     (
     )


I want there to be a way to tell which dir the file is in similar to a tree

<?php
error_reporting(E_ALL);

$myArray = array();

function readDirs($path){
  $dirHandle = opendir($path);
  while($item = readdir($dirHandle)) {
    $newPath = $path."/".$item;
    if(is_dir($newPath) && $item != '.' && $item != '..') {
       echo "Found Folder $newPath<br>";
        $myArray['dirs'][] = $newPath;
       readDirs($newPath);
    }
    else{
      echo '&nbsp;&nbsp;Found File or .-dir '.$item.'<br>';
        $myArray['files'][] = $newPath;
    }
  }
  return $myArray;
}

$path =  ".";
echo "$path<br>";

$myArray = readDirs($path);

echo '<pre>';
print_r($myArray);

Open in new window

LVL 1
rgb192Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ray PaseurConnect With a Mentor Commented:
There may be a germ of an idea in the SPL:
http://php.net/manual/en/class.recursivedirectoryiterator.php
0
 
rgb192Author Commented:
so I need to learn more about the spl

thank you
0
All Courses

From novice to tech pro — start learning today.