如题:需要把有父子结构的二维数组,把这个树形结构的分支路径全部遍历出来,组成一个新的数组,最好用php语言,求大佬给个算法
原始数组为
$array = [ ['ID'=>'A','SD'=>'B'], ['ID'=>'A','SD'=>'C'], ['ID'=>'A','SD'=>'D'], ['ID'=>'B','SD'=>'E'], ['ID'=>'B','SD'=>'F'], ['ID'=>'E','SD'=>'G'], ['ID'=>'C','SD'=>'H'], ['ID'=>'C','SD'=>'I'] ];
转化后的数组为:
$targe = [ ['B','E','G'], ['B','F'], ['C','H'], ['C','I'], ['D'] ]