[ create a new paste ] login | about

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

print_dir($map);


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


Create a new paste based on this one


Comments: