Exemplo n.º 1
0
 /**
  * @param $path
  * @param $base_path
  *
  * @return array
  */
 public static function recursiveDirectory($path, $base_path)
 {
     $array = array();
     $items = scandir($path);
     foreach ($items as $item) {
         if ($item != "." && $item != "..") {
             if (is_file($path . "/" . $item)) {
                 $array[]['item'] = array('is_dir' => FALSE, 'path' => $path, 'relative' => str_replace($base_path, '', $path), 'file' => $item, 'extension' => AppFile::fileExtension($item));
             }
         }
     }
     foreach ($items as $item) {
         if ($item != "." && $item != "..") {
             if (is_dir($path . "/" . $item)) {
                 $array[]['item'] = array('is_dir' => TRUE, 'path' => $path, 'relative' => str_replace($base_path, '', $path), 'folder' => $item, 'depth' => AppFile::folderCountInPath(str_replace($base_path, '', $path . "/" . $item)), 'sub_folders' => AppFile::recursiveDirectory($path . "/" . $item, $base_path));
             }
         }
     }
     return $array;
 }