[ create a new paste ] login | about

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

PHP, pasted on Oct 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
    $td = array(1=>array(5=>array(3=>'testvalue1',array(6=>'testvalue2'))),2=>array(6=>'testvalue2',array(6=>'testvalue2',array(6=>'testvalue2'),array(6=>'testvalue2',array(6=>'testvalue2')))),3=>'testvalue3',4=>'testvalue4');
    print_r($td);
    $toc = '';

    function TOC($arr,$ke='',$l=array()) {
            if (is_array($arr)) {
            if ($ke != '') array_push($l,$ke);
            foreach($arr as $k => $v)
                TOC($v,$k,$l);
        }
        else {
            array_push($l,$ke);
            $GLOBALS['toc'].=implode('.',$l)." = $arr\n";
        }
    }
    toc($td);
    echo "\n\n".$toc;
?>


Output:
Array
(
    [1] => Array
        (
            [5] => Array
                (
                    [3] => testvalue1
                    [4] => Array
                        (
                            [6] => testvalue2
                        )

                )

        )

    [2] => Array
        (
            [6] => testvalue2
            [7] => Array
                (
                    [6] => testvalue2
                    [7] => Array
                        (
                            [6] => testvalue2
                        )

                    [8] => Array
                        (
                            [6] => testvalue2
                            [7] => Array
                                (
                                    [6] => testvalue2
                                )

                        )

                )

        )

    [3] => testvalue3
    [4] => testvalue4
)


1.5.3 = testvalue1
1.5.4.6 = testvalue2
2.6 = testvalue2
2.7.6 = testvalue2
2.7.7.6 = testvalue2
2.7.8.6 = testvalue2
2.7.8.7.6 = testvalue2
3 = testvalue3
4 = testvalue4


Create a new paste based on this one


Comments: