我有下一个多维数组:
Array
(
[0] => Array
(
[id] => 1
[name] => Category 1
[parent] => 0
[children] => Array
(
[0] => Array
(
[id] => 3
[name] => Sub 1
[parent] => 1
[children] => Array
(
)
)
[1] => Array
(
[id] => 4
[name] => Sub 2
[parent] => 1
[children] => Array
(
[0] => Array
(
[id] => 6
[name] => Sub Sub 4
[parent] => 4
[children] => Array
(
)
)
)
)
)
)
[1] => Array
(
[id] => 2
[name] => Category 2
[parent] => 0
[children] => Array
(
[0] => Array
(
[id] => 5
[name] => Sub 3
[parent] => 2
[children] => Array
(
)
)
)
)
)
我需要在页面上用不同的缩进呈现这个数组。例如:
- 第一类
- 子 1
- 子 2
- 子子 4
- 第 2 类
- 子 3
我知道我可以使用 SPL RecursiveArrayIterator,但我不知道怎么做。你能帮我吗,如何渲染这样的数组?