where("pid=$id")->order("sort asc")->s">
时间:2021-07-01 10:21:17 帮助过:36人阅读
public function _getMenu($id=0,$t=0){ $category = M("category"); $data = $category->where("pid=$id")->order("sort asc")->select(); if($data){ $t++; $data2['leavel'] = $t; $category->where("pid=$id")->save($data2); //层级 foreach($data as $key=>$value){ $sort = $value['sort']; $id = $value['id']; $this->str .= ''; $this->_getMenu($value['id'],$t); } } } '; $this->str .= " ". $value['id']." "; if($t>1){ if() $this->str .= "|-----".$value['name']." "; }else{ $this->str .= "".$value['name']." "; } $this->str .= "".$value['group']." "; $id = $value['id']; $this->str .= '删除
就是想问下,最后自分类最后一个用|__而不是|--
那你就要判断当前父类下 所有栏目数是否等于本栏目位置(第几条),如果相等,则就是最后一条,就满足你的要求了
分类数组为 $data 则
end($data);
$ek = key($data); //之后一个分类在 $data 中的键值
循环中加入
if($key == $ek) $this->str .= "