我在PHP中有一个多维数组,看起来像下面的代码:
Array
(
[0] => Array
(
[ID] => 6898
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 8214
[ParentID] => 6898
)
[1] => Array
(
[ID] => 5595
[ParentID] => 6898
[children] => Array
(
[0] => Array
(
[ID] => 7238
[ParentID] => 5595
)
)
)
)
)
[1] => Array
(
[ID] => 8216
[ParentID] =>
)
[2] => Array
(
[ID] => 7046
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 5555
[ParentID] => 7046
[children] => Array
(
[0] => Array
(
[ID] => 7294
[ParentID] => 5555
)
)
)
[1] => Array
(
[ID] => 5706
[ParentID] => 7046
)
)
)
[3] => Array
(
[ID] => 5884
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7431
[ParentID] => 5884
[children] => Array
(
[0] => Array
(
[ID] => 5618
[ParentID] => 7431
)
)
)
[1] => Array
(
[ID] => 6993
[ParentID] => 5884
)
)
)
[4] => Array
(
[ID] => 6002
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 5801
[ParentID] => 6002
)
[1] => Array
(
[ID] => 6615
[ParentID] => 6002
[children] => Array
(
[0] => Array
(
[ID] => 6595
[ParentID] => 6615
)
)
)
)
)
[5] => Array
(
[ID] => 8119
[ParentID] =>
)
[6] => Array
(
[ID] => 8116
[ParentID] =>
)
[7] => Array
(
[ID] => 5992
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7614
[ParentID] => 5992
[children] => Array
(
[0] => Array
(
[ID] => 7647
[ParentID] => 7614
)
)
)
[1] => Array
(
[ID] => 8215
[ParentID] => 5992
)
)
)
[8] => Array
(
[ID] => 5690
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 8188
[ParentID] => 5690
)
[1] => Array
(
[ID] => 5678
[ParentID] => 5690
)
)
)
[9] => Array
(
[ID] => 5825
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 6842
[ParentID] => 5825
)
[1] => Array
(
[ID] => 5653
[ParentID] => 5825
[children] => Array
(
[0] => Array
(
[ID] => 6490
[ParentID] => 5653
[children] => Array
(
[0] => Array
(
[ID] => 7737
[ParentID] => 6490
)
)
)
)
)
)
)
[10] => Array
(
[ID] => 8114
[ParentID] =>
)
[11] => Array
(
[ID] => 8113
[ParentID] =>
)
[12] => Array
(
[ID] => 7826
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7871
[ParentID] => 7826
[children] => Array
(
[0] => Array
(
[ID] => 5891
[ParentID] => 7871
)
)
)
[1] => Array
(
[ID] => 5983
[ParentID] => 7826
)
)
)
)
Array
(
[0] => Array
(
[ID] => 6898
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 8214
[ParentID] => 6898
)
[1] => Array
(
[ID] => 5595
[ParentID] => 6898
[children] => Array
(
[0] => Array
(
[ID] => 7238
[ParentID] => 5595
)
)
)
)
)
[1] => Array
(
[ID] => 8216
[ParentID] =>
)
[2] => Array
(
[ID] => 7046
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 5555
[ParentID] => 7046
[children] => Array
(
[0] => Array
(
[ID] => 7294
[ParentID] => 5555
)
)
)
[1] => Array
(
[ID] => 5706
[ParentID] => 7046
)
)
)
[3] => Array
(
[ID] => 5884
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7431
[ParentID] => 5884
[children] => Array
(
[0] => Array
(
[ID] => 5618
[ParentID] => 7431
)
)
)
[1] => Array
(
[ID] => 6993
[ParentID] => 5884
)
)
)
[4] => Array
(
[ID] => 6002
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 5801
[ParentID] => 6002
)
[1] => Array
(
[ID] => 6615
[ParentID] => 6002
[children] => Array
(
[0] => Array
(
[ID] => 6595
[ParentID] => 6615
)
)
)
)
)
[5] => Array
(
[ID] => 8119
[ParentID] =>
)
[6] => Array
(
[ID] => 8116
[ParentID] =>
)
[7] => Array
(
[ID] => 5992
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7614
[ParentID] => 5992
[children] => Array
(
[0] => Array
(
[ID] => 7647
[ParentID] => 7614
)
)
)
[1] => Array
(
[ID] => 8215
[ParentID] => 5992
)
)
)
[8] => Array
(
[ID] => 5690
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 8188
[ParentID] => 5690
)
[1] => Array
(
[ID] => 5678
[ParentID] => 5690
)
)
)
[9] => Array
(
[ID] => 5825
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 6842
[ParentID] => 5825
)
[1] => Array
(
[ID] => 5653
[ParentID] => 5825
[children] => Array
(
[0] => Array
(
[ID] => 6490
[ParentID] => 5653
[children] => Array
(
[0] => Array
(
[ID] => 7737
[ParentID] => 6490
)
)
)
)
)
)
)
[10] => Array
(
[ID] => 8114
[ParentID] =>
)
[11] => Array
(
[ID] => 8113
[ParentID] =>
)
[12] => Array
(
[ID] => 7826
[ParentID] =>
[children] => Array
(
[0] => Array
(
[ID] => 7871
[ParentID] => 7826
[children] => Array
(
[0] => Array
(
[ID] => 5891
[ParentID] => 7871
)
)
)
[1] => Array
(
[ID] => 5983
[ParentID] => 7826
)
)
)
)
这是我想要传递两个节点ID的分层数组 - > getLevelDifference(7826,5891)它应该给出2作为结果或一个函数,我可以得到那个级别的子数组,如 - > getLevelChild(7826,2)它应该返回5891作为结果或同级别的其他子项?