Home > php教程 > php手册 > 菜单啊菜单

菜单啊菜单

WBOY
Release: 2016-06-07 11:42:31
Original
1696 people have browsed it

以前写的代码,竟然看不懂了。。。。花了整整两天时间。。。。
备注一下
//功能主要是无限分级菜单<br> $M=M('Menu');<br> $condition=array('is_deleted'=>'0','status' =>'1');<br> $result=$M->field("id,level,pid,name")->where($condition)->order('level')->select();<br> //转换成数组,同级节点的索引值相同<br>  $index[0]=0;<br>         foreach ($result as $key => $value) {<br>             $data[$value['level']][$key][$value['id']]=$value['name'];<br>             $index[$value['id']]=$key;<br>         }<br> //倒序将当前级添加为上级的子节点<br>         foreach (array_reverse($data,true) as $key => $value) {<br>             foreach ($value as $k => $v) {<br>                 $data[$key-1][$index[$result[$k]['pid']]][$k]=$data[$key][$k]; <br>             }          <br>             unset($data[$key]);<br>         }<br> dump($data[0]);

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template