title: print a tree in a table format from an array
body: <p>Hi I am trying to print an array which has node value and depth parameters as a tree in table format like below.</p>
  
  <p>My Current code which will print as a tree view format below:</p>
  
  <pre><code>if(count($nodes) &gt; 0){
      $depth = -1;
      $flag = false;
      foreach ($nodes as $row) {
          while ($row-&gt;depth &gt; $depth) {
              echo "&lt;ul&gt;&lt;li&gt;&lt;a href='javascript:void(0);'&gt;";
              $flag = false;
              $depth++;
          }
          while ($row-&gt;depth &lt; $depth) {
              echo "&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;";
              $depth--;
          }
          if ($flag) {
              echo "&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href='javascript:void(0);'&gt;";
              $flag = false;
          }
          echo $row-&gt;name.'&lt;button type="button" class="btn btn-danger margin-left-20 removeBtn" data-name="'.$row-&gt;name.'"&gt;Delete&lt;/button&gt;' ;
          $flag = true;
      }
      while ($depth-- &gt; -1) {
          echo "&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;";
      }
  }else{
      echo '&lt;div class="alert alert-warning"&gt;&lt;strong&gt;Warning!&lt;/strong&gt; There were no nodes in the tree!&lt;/div&gt;';
  }
  </code></pre>
  
  <p>Example Array: </p>
  
  <pre><code>Value  Depth
  
  12       0
  
  13       1
  
  14       1
  
  25       2
  
  20       2
  
  21       2
  
  16       2
  
  23       3
  
  24       3
  </code></pre>
  
  <p>I am able to print in a normal tree view but when i am trying to print as a table format i can't able to do it somehow.</p>
  
  <p>Expected Format:</p>
  
  <p>Table first row 12[0] entire row</p>
  
  <p>Table second row will be shared by 13[1] and 14[1]</p>
  
  <p>Table third row will be shared by 25[2], 20[2] and 21[]2</p>
  
  <p>Table fourth row will be shared by 16[3], 23[3] and 24[3]</p>
  
  <p>So logic is each row of the table will be shared equally by the same depth node values.</p>