【发布时间】:2015-06-25 12:07:39
【问题描述】:
我有一个数组(来自邻接表的数据),它看起来像:
Array
(
[0] => Array
(
[id] => 1
[name] => Anniversary
[parent] => 0
)
[1] => Array
(
[id] => 12
[name] => New arrives
[parent] => 1
)
[2] => Array
(
[id] => 13
[name] => Discount
[parent] => 12
)
[3] => Array
(
[id] => 6
[name] => Birthday
[parent] => 0
)
)
我正在寻找通过 ID 检索路径的方法;
For example: getPath(13): Anniversary->New arrives->Discount;
For example: getPath(12): Anniversary->New arrives;
For example: getPath(1): Anniversary;
For example: getPath(6): Birthday;
我该怎么做? 谢谢!
【问题讨论】:
-
你已经尝试过什么
标签: php arrays adjacency-list