我有这个任务的麻烦。我是 PHP 新手。我想我必须使用递归函数,但我不明白它是如何使用的
我有一个这样的数组:
Array
(
[0] => Array
(
[id] => 1
[parent_id] => 0
[name] => New Folder
)
[1] => Array (
[id] => 2
[parent_id] => 1
[name] => New Folder2
)
[2] => Array
(
[id] => 3
[parent_id] => 2
[name] => New Folder3
)
......
[5] => Array
(
[id] => 6
[parent_id] => 0
[name] => New Folder6
)
[6] => Array (
[id] => 7
[parent_id] => 6
[name] => New Folder7
)
[7] => Array
(
[id] => 8
[parent_id] => 6
[name] => New Folder8
)
)
我需要像这样构建目录的路径:
/New Folder
/New Folder/New Folder2
/New Folder/New Folder2/New Folder3
...
/New Folder6
/New Folder6/New Folder7
/New Folder6/New Folder8
你能帮我完成这个任务吗?谢谢。