将上面的数组生成一个树形管理权限结构数组
时间: 2024-05-15 12:16:21 浏览: 42
```
$permissions = [
[
'id' => 1,
'name' => '用户管理',
'pid' => 0,
'children' => [
[
'id' => 2,
'name' => '添加用户',
'pid' => 1,
'children' => []
],
[
'id' => 3,
'name' => '修改用户',
'pid' => 1,
'children' => []
],
[
'id' => 4,
'name' => '删除用户',
'pid' => 1,
'children' => []
]
]
],
[
'id' => 5,
'name' => '角色管理',
'pid' => 0,
'children' => [
[
'id' => 6,
'name' => '添加角色',
'pid' => 5,
'children' => []
],
[
'id' => 7,
'name' => '修改角色',
'pid' => 5,
'children' => []
],
[
'id' => 8,
'name' => '删除角色',
'pid' => 5,
'children' => []
]
]
],
[
'id' => 9,
'name' => '权限管理',
'pid' => 0,
'children' => [
[
'id' => 10,
'name' => '添加权限',
'pid' => 9,
'children' => []
],
[
'id' => 11,
'name' => '修改权限',
'pid' => 9,
'children' => []
],
[
'id' => 12,
'name' => '删除权限',
'pid' => 9,
'children' => []
]
]
]
];
```
阅读全文