title: Echo a multidimensional array in PHP
body: <p>I have a multidimensional array and I'm trying to find out how to simply "echo" the elements of the array. The depth of the array is not known, so it could be deeply nested.</p>
  
  <p>In the case of the array below, the right order to echo would be:</p>
  
  <pre><code>This is a parent comment
  This is a child comment
  This is the 2nd child comment
  This is another parent comment
  </code></pre>
  
  <p>This is the array I was talking about:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [comment_id] =&gt; 1
              [comment_content] =&gt; This is a parent comment
              [child] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [comment_id] =&gt; 3
                              [comment_content] =&gt; This is a child comment
                              [child] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [comment_id] =&gt; 4
                                              [comment_content] =&gt; This is the 2nd child comment
                                              [child] =&gt; Array
                                                  (
                                                  )
                                          )
                                  )
                          )
                  )
          )
  
      [1] =&gt; Array
          (
              [comment_id] =&gt; 2
              [comment_content] =&gt; This is another parent comment
              [child] =&gt; Array
                  (
                  )
          )
  )
  </code></pre>