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

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

    If you have XML as input, why not use XSLT to transform it to

      ?

      I guess your input looks something like this (I assume "NavigationMode" is a typo):

      
        
          Introduction
          
            Sub Intro
          
        
        
          Module 1
        
      
      

      With a small XSLT 1.0 stylesheet:

      
      
        
      
        
          
    • This output is produced:

      • Introduction
        • Sub Intro
      • Module 1

      The PHP documentation shows how to use XSLT. It's simple.

提交回复
热议问题