[ create a new paste ] login | about

Link: http://codepad.org/PEG0yuCr    [ 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,$path)
{
    $buff = '';
    foreach ($in as $k => $v)
    {
        if (!is_array($v))
            $buff .= "[file]: ".$path.$v."\n";
        else
            $buff .= "[directory]: ".$path.$k."\n".print_dir($v,$path.$k.DIRECTORY_SEPARATOR);
    }
    return $buff;
}

echo print_dir($map,'');


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


Create a new paste based on this one


Comments: