Here's a little function i use to traverse an array
of arbitrary complexity... it uses recursion.

function array_traverse ($ary, $b=array()) {

  while ( list($k,$v) = each($ary) ) {
        print (join("", $b)) . "$k = $v\n";

        array_push($b, "\t");
        if ( is_array($ary[$k]) ) {
                array_traverse($ary[$k], $b);
        }
        array_pop($b);

  }

  return 1;
}


with the data:
$x = array(
        '1'=> array(
                'one'   => 'first',
        ),
        '2'=> array(
                'two'   => 'second',
                'second'=> 'two',
        )
);

it will print:
1 = Array
        one = first
2 = Array
        two = second
        second = two

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to