PHP: How to generate a
  • tree in an xml2assoc array result?

后端 未结 3 781
名媛妹妹
名媛妹妹 2021-01-16 00:06

I have seen many PHP function on how to generate a

  • tag but my array input is quite complicated I guess. It is an array returned from a cust
3条回答
  •  广开言路
    2021-01-16 00:45

    i didn't test it for variations of the demo data ...

     0) {
            $out = '
  • ' . $title . "\n" . '
      '; foreach ($cnodes as $cnode) { $out .= runTree($cnode); } $out .= '
    ' . "\n" . '
  • ' . "\n"; return $out; } else { return '
  • ' . $title . '
  • ' . "\n"; } } $tree = array( 0 => array( 'tag' => 'NavigationMode', 'value' => array( 0 => array( 'tag' => 'Title', 'value' => 'Introduction' ), 1 => array( 'tag' => 'NavigationNode', 'value' => array( 0 => array( 'tag' => 'Title', 'value' => 'Sub Intro' ) ) ) ) ), 1 => array( 'tag' => 'NavigationMode', 'value' => array( 0 => array( 'tag' => 'Title', 'value' => 'Module 1' ) ) ) ); echo '
      '; foreach ($tree as $node) { echo runTree($node); } echo '
    '; ?>

提交回复
热议问题