周梦康 发表于 2019-09-30 264 次浏览 标签 : 面试吐槽

有一个数组

[
    ["id" => 1,"name" => "a"],
    ["id" => 2,"name" => "b"],
    ["id" => 3,"name" => "c"],
    ["id" => 4,"name" => "d","pid" => 1],
    ["id" => 5,"name" => "e","pid" => 2],
    ["id" => 6,"name" => "f","pid" => 5],
    ["id" => 7,"name" => "g","pid" => 5],
    ["id" => 8,"name" => "h","pid" => 7],
];

通过一个函数将其树状结构输出返回。

评论列表