title: How to convert a multi-level array to ul?
body: <p>I have the following array.</p>
  
  <pre><code>    Array
  (
      [24] =&gt; Array
          (
              [id] =&gt; 24
              [name] =&gt; Main menu
              [shortdesc] =&gt; mainmenu
              [status] =&gt; active
              [parentid] =&gt; 0
              [order] =&gt; 0
              [children] =&gt; Array
                  (
                      [65] =&gt; Array
                          (
                              [id] =&gt; 65
                              [name] =&gt; Main 4
                              [shortdesc] =&gt; 
                              [status] =&gt; active
                              [parentid] =&gt; 24
                              [order] =&gt; 0
                              [children] =&gt; Array
                                  (
                                  )
  
                          )
  
                      [64] =&gt; Array
                          (
                              [id] =&gt; 64
                              [name] =&gt; Main 3
                              [shortdesc] =&gt; 
                              [status] =&gt; active
                              [parentid] =&gt; 24
                              [order] =&gt; 0
                              [children] =&gt; Array
                                  (
                                  )
  
                          )
  
                     ...
                     ...
  
                      [59] =&gt; Array
                          (
                              [id] =&gt; 59
                              [name] =&gt; Main 1
                              [shortdesc] =&gt; 
                              [status] =&gt; active
                              [parentid] =&gt; 24
                              [order] =&gt; 0
                              [children] =&gt; Array
                                  (
                                      [66] =&gt; Array
                                          (
                                              [id] =&gt; 66
                                              [name] =&gt; Main 1-1
                                              [shortdesc] =&gt; 
                                              [status] =&gt; active
                                              [parentid] =&gt; 59
                                              [order] =&gt; 0
                                              [children] =&gt; Array
                                                  (
                                                  )
  
                                          )
  
                                  )
  
                          )
  
                  )
  
          )
  
      [25] =&gt; Array
          (
              [id] =&gt; 25
              [name] =&gt; Galleri 1
              [shortdesc] =&gt; galleri1
              [status] =&gt; active
              [parentid] =&gt; 0
              [order] =&gt; 0
              [children] =&gt; Array
                  (
                  )
  
          )
  
  )
  </code></pre>
  
  <p>And I want to convert this to the following HTML by php.</p>
  
  <pre><code>&lt;ul&gt;
     &lt;li&gt;Main menu
          &lt;ul&gt;
              &lt;li&gt;Main 4&lt;/li&gt;
              &lt;li&gt;Main 3&lt;/li&gt;
              ...
              &lt;li&gt;Main 1
                  &lt;ul&gt;
                      &lt;li&gt;Main 1-1&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li&gt;Galleri 1&lt;/li&gt;
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>I started like this, but I am stuck.</p>
  
  <pre><code>if (count($navlist)){
    echo "\n&lt;ul&gt;";
    foreach ($navlist as $key =&gt; $list){
  ...
  ...
  </code></pre>