话不多说,请看代码:
where("class_pid = $assortPid")->field('class_id,class_name')->select();
foreach ($assort as $value) {
$tree .= '
db->select($field)->get('access');
$q_result = $q_access->result_array();
if (!empty($q_result)) {
$items = array();
foreach ($q_result as $value) {
$items[$value['id']] = $value;
}
foreach ($items as $key => $item) {
if ($item['pid'] == 0) {
$access[] = &$items[$key];
} else {
$items[$item['pid']]['sub_access'][] = &$items[$key];
}
}
}
return $access;
}
原文链接:https://www.f2er.com/php/17831.html