开发者

How to make dir tree from array

I haw got a array of directory's that i wont to use for the directory tree with this code below... My question is how to make a tree from this array? With this code I get this:

Array (
    [0] => store/555555//Osnovni documenti
    [1] => store/555555//Ostali dokumenti
    [2] => store/555555//Pictures )

NOW how to inplement this ?sou I can get the directory tree ? Is ther something that can do that?

echo"<pre>";

function make_tree_recursive($path, $levels){
//where $path is your source dir, $levels is the maximum recursives
    $handle=opendir($path);
    while($a=readdir($handle)){
      if(!preg_match('/^\./',$a)){
        $full_path="$path/$a";
        $list[]=$full_path;

      开发者_StackOverflow中文版  if((is_dir($full_path))&&(!preg_match('/(\/.+){'.$levels.',}/',$full_path))){
          $recursive=make_tree_recursive($full_path, $levels);
          for($n=0; $n<count($recursive); $n++){
              $list[]=$recursive[$n];
          }
        }
      }
    }

    closedir($handle);
    return $list;
}

$list = make_tree_recursive("store/".$diro."/", 3);
print_r ($list);
echo"</pre>";


flip path array using array_flip and use the library explodeTree

// let '/' be our delimiter
$tree = explodeTree($key_files, "/");
// show the array
print_r($tree);

http://kevin.vanzonneveld.net/techblog/article/convert_anything_to_tree_structures_in_php/


cat <<000 >a0.a
aa/store
aa/store/555555
aa/store/555555/Osnovni documenti
aa/store/555555/Ostali dokumenti
aa/store/555555/Pictures
000

cat a0.a |
    grep -P . |
    while read d0; do echo --- $d0; mkdir -pv $PWD/aa/"$d0"
        done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜