[ create a new paste ] login | about

Link: http://codepad.org/y2qE59XS    [ raw code | output | fork ]

PHP, pasted on Aug 24:
<?php
$map = Array
    (
        0 => "test.txt",
        'two' => Array
            (
                0 => "test.txt",
                'testing' => Array
                    (
                        0 => "testagain.txt"
                    )
     
            ),
     
        "three" => Array
            (
                0 => "testthree.txt"
            ),
     
        1 => "test.txt",
        "one" => Array
            (
                0 => "testone.txt",
                "subone" => Array
                    (
                        0 => "testsubone.txt"
                    )
     
            )
     
    );


function print_dir($in,$depth)
{
    foreach ($in as $k => $v)
    {
        if (!is_array($v))
            echo str_repeat("   ",$depth),$v," [file]\n";
        else
            echo str_repeat("   ",$depth),$k," [directory]\n",print_dir($v,$depth+1);
    }
}

print_dir($map,0);


Output:
1
2
3
4
5
6
7
8
9
10
11
12
test.txt [file]
two [directory]
   test.txt [file]
   testing [directory]
      testagain.txt [file]
three [directory]
   testthree.txt [file]
test.txt [file]
one [directory]
   testone.txt [file]
   subone [directory]
      testsubone.txt [file]


Create a new paste based on this one


Comments: