我有一个数组:
Array
(
[0] => dir0|file0.txt
[1] => dir0|file1.txt
[2] => dir1|file2.txt
[3] => dir1|filea.txt
[4] => dir2|fileb.txt
)
我希望它显示为一棵树,例如:
dir0
file0.txt
file1.txt
dir1
file2.txt
filea.txt
dir2
fileb.txt
谁能解释我该怎么做?
编辑:更新了多维数组:
$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;
我希望输出为:
dir0 (900)
file0.txt (400)
filea.txt (500)
dir1 (1300)
file1.txt(600)
fileb.txt (700)
dir2 (700)
filec.txt (700)
这些值需要添加并显示在根目录中。