title: convert an 1D array to multidimensional array in PHP
body: <p>I have this array:</p>
  
  <pre><code>Array
  (
      [1] =&gt; animal
      [1-1] =&gt; turtle
      [1-1-1] =&gt; sea turtle
      [1-1-2] =&gt; box turtle
      [1-1-3] =&gt; green turtle
      [1-1-3-1] =&gt; green turtle with brown tail
  )
  </code></pre>
  
  <p>and I want some how to convert it into:</p>
  
  <pre><code>Array
  (
      [1-title] =&gt; animal
      [1-sons] =&gt; array(
              [1-1-title] =&gt; turtle
              [1-1-sons] =&gt; array(
                      [1-1-1] =&gt; sea turtle
                          [1-1-2] =&gt; box turtle
                      [1-1-3-title] =&gt; green turtle
                      [1-1-3-sons] =&gt; array(
                              [1-1-3-title] =&gt; green turtle
                                    )
                      )
                )
  )
  </code></pre>
  
  <p>or maybe you can suggest a better way for organizing the outputted array..</p>
  
  <p>but how to do that?</p>
  
  <p>I know that's not easy task at all, I'm writing a parser that will walk on data and make tree out of them..</p>
  
  <p>Thanks in advance for your help and advices..</p>