例如,我有数组
Array
(
[0] => folder1/file1.txt
[1] => folder1/file2.txt
[2] => file2.txt
[3] => folder2/file1.txt
[4] => folder1/subfolder1/file1.txt
[5] => folder1/subfolder2/file2.txt
[6] => file1.txt
[7] => file3.txt
[8] => folder1/subfolder2/file1.txt
)
我需要一个线索来确定如何根据给定的值创建“目录树”数组,它可能如下所示:
Array
(
[folder1] => Array
(
[0] => file1.txt
[1] => file2.txt
[subfolder1] => Array
(
[0] => file1.txt
)
[subfolder2] => Array
(
[0] => file1.txt
[1] => file2.txt
)
)
[0] => file1.txt
[1] => file2.txt
[2] => file3.txt
)
现在第二个数组是第一个数组的树(手动制作)。=)
而且我不知道如何自动实现这一点。