【发布时间】:2016-11-15 09:22:12
【问题描述】:
我有示例层次结构:
id name parent
1 a null
2 b 1
3 c 2
4 d 2
5 e 2
6 f 1
7 g 6
8 h 6
9 i 6
如果我想在“c”和“g”之间或“c”和“e”之间搜索父母。我怎么做? 我已经尝试过来自here 的脚本 但是我找不到解决问题的方法,有人可以帮助我吗?我不是算法专家,请帮忙处理php代码
我想要输出
如果“c”和“g”我想输出“a”,如果“c”和“e”我想输出“b”
【问题讨论】:
-
parent between "c" and "g"是什么意思,它应该返回"a,b,f"吗?你能添加预期的输出吗? -
如果“c”和“g”我想返回“a”,如果“c”和“e”我想返回“b”