PHP数组 二级菜单
PHP多级菜单 foreach循环数组二级菜单
PHP多级菜单数组循环实现
- $navlist = array( //一级菜单
- '1'=>array('name'=>'内容管理','icon'=>'<i class="icon-th"></i>','url'=>'url'),
- '2'=>array('name'=>'投票管理','icon'=>'<i class="icon-th"></i>','url'=>'url'),
- '3'=>array('name'=>'代码管理','icon'=>'<i class="icon-th"></i>','url'=>'url'),
- '4'=>array('name'=>'网友信息','icon'=>'<i class="icon-th"></i>','url'=>'url'),
- '5'=>array('name'=>'账号管理','icon'=>'<i class="icon-user"></i>','url'=>'url'),
- '6'=>array('name'=>'专题配置','icon'=>'<i class="icon-cog"></i>','url'=>'url'),
- );
- $menulist = array( //二级菜单
- '1'=>array(
- array('name'=>'新增内容','icon'=>'icon','url'=>'url'),
- array('name'=>'内容管理','icon'=>'icon','url'=>'url'),
- ),
- '2'=>array(
- array('name'=>'新增选项','icon'=>'icon','url'=>'url'),
- array('name'=>'投票设置','icon'=>'icon','url'=>'url'),
- ),
- '3'=>array(
- array('name'=>'评论代码','icon'=>'icon','url'=>'url'),
- ),
- '4'=>array(
- array('name'=>'网友列表','icon'=>'icon','url'=>'url'),
- array('name'=>'信息导出','icon'=>'icon','url'=>'url'),
- ),
- '5'=>array(
- array('name'=>'新增账号','icon'=>'icon','url'=>'url'),
- array('name'=>'分组管理','icon'=>'icon','url'=>'url'),
- array('name'=>'账号列表','icon'=>'icon','url'=>'url'),
- ),
- '6'=>array(
- array('name'=>'专题管理','icon'=>'icon','url'=>'url'),
- array('name'=>'分类管理','icon'=>'icon','url'=>'url'),
- array('name'=>'发布配置','icon'=>'icon','url'=>'url'),
- array('name'=>'权限配置','icon'=>'icon','url'=>'url'),
- )
- );
调用测试:
- foreach($navlist as $key => $row){
- echo '<b>'.$row['name'].'</b>
- ';
- foreach($menulist[$key] as $i => $val){
- echo ' ├'.$val['name'].'
- ';
- }
- echo '
- ';
- }
本文作者:未来往事
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
此处评论已关闭