Displaying array as tree structure in php
<p>Hello i have an array </p>

<pre><code>Array
(
    [0] =&gt; dir0|file0.txt
    [1] =&gt; dir0|file1.txt
    [2] =&gt; dir1|file2.txt
    [3] =&gt; dir1|filea.txt
    [4] =&gt; dir2|fileb.txt
)
</code></pre>

<p>This need to be displayed as a tree like</p>

<pre><code>dir0
  file0.txt
  file1.txt
dir1 
  file2.txt
  filea.txt
dir2
  fileb.txt
</code></pre>

<p>can any one explain how can i do that.</p>

<p>Updated for multidimentional </p>

<pre><code>$paths[0][0]='dir0|file0.txt';
$paths[0][1]=400;
$paths[1][0]='dir0|filea.txt';
$paths[1][1]=500;
$paths[2][0]='dir1|file1.txt';
$paths[2][1]=600;
$paths[3][0]='dir1|fileb.txt';
$paths[3][1]=700;
$paths[4][0]='dir2|filec.txt';
$paths[4][1]=700;
</code></pre>

<p>i need a sample display like </p>

<pre><code>dir0 (900)
  file0.txt (400)
  filea.txt (500)
dir1 (1300)
  file1.txt(600)
  fileb.txt (700)
dir2 (700)
  filec.txt (700)
</code></pre>

<p>the values needed to be added and displayed in root.</p>
