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

后端 未结 3 782
名媛妹妹
名媛妹妹 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:43

    Here is a quick PHP implementation for your array structure to get you started:

    function create_html_list($nodes)
    {
        echo '
      '; foreach ($nodes as $node) { $childNodes = $node['value']; $titleNode = array_shift($childNodes); echo "
    • ", $titleNode['value']; if (count($childNodes) > 0) { create_html_list($childNodes); } echo "
    • "; } echo '
    '; }

提交回复
热议问题