**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
给定一个已知的层次结构,例如:
group
|__unit
|__department
|__team
我可以创建一个嵌套数组,它与给定的一组独立数组的层次结构相匹配吗?
例如,以下输入:
[
["group" => "group2"],
["group" => "group2", "unit" => "unit11", "department" => "department50", "team" => "team10"],
["group" => "group2", "unit" => "unit11", "department" => "department50", "team" => "team58"],
["group" => "group2", "unit" => "unit10"],
["group" => "group5", "unit" => "unit23"],
["group" => "group5", "unit" => "unit23", "department" => "department101"]
]
我可以迭代这些项并创建一个具有层次结构的嵌套数组吗,如下所示:
[
"group2" => [
"unit11" => [
"department50" => [
["team10"],
["team58"]
],
],
"unit10" => [],
],
"group5" => [
"unit23" => [
"department101" => []
],
],
]
或者类似?
1条答案
按热度按时间xqkwcwgp1#
遍历数据并创建相应的实体。将对这些实体的引用存储在帮助器普通列表中,以便按名称访问它们。