refactor: 修改递归函数level计算错误
This commit is contained in:
@@ -15,11 +15,12 @@ if (!function_exists('array_to_tree')) {
|
||||
$ret = [];
|
||||
foreach ($data as $item) {
|
||||
if ($item[$with] == $pid) {
|
||||
$lv = $level;
|
||||
if ($level !== false) {
|
||||
$item['level'] = $level;
|
||||
$level = $level + 1;
|
||||
$lv = $level + 1;
|
||||
}
|
||||
$children = array_to_tree($data, $item['id'], $with, $level);
|
||||
$children = array_to_tree($data, $item['id'], $with, $lv);
|
||||
if ($children) {
|
||||
$item['children'] = $children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user