$cate 所有的菜单
$id 当前菜单id
//递归查询父级菜单名 public function getTopParent($cate,$id){ $arr=array(); foreach($cate as $v){ if($v['id']==$id){ $arr[]=$v['name'];// $v['name'] 菜单名字 $arr=array_merge($this->getTopParent($cate,$v['parentid']),$arr); } } return $arr; }