把一维数组处理成二维数组

array (size=3)
  '幸运抽奖' => 
    array (size=4)
      '开宝箱' => string 'http://baidu.com' (length=16)
      '大转盘' => string '' (length=0)
      '砸金蛋' => string '' (length=0)
      '刮刮乐' => string '' (length=0)
  '积分兑换' => 
    array (size=4)
      '兑换砖石' => string '' (length=0)
      '兑换体力' => string '' (length=0)
      '兑换金币' => string '' (length=0)
      '兑换VIP卡' => string '' (length=0)
  '个人中心' => 
    array (size=5)
      '我的订单' => string '' (length=0)
      '我的积分' => string '' (length=0)
      '积分排名' => string '' (length=0)
      '兑换记录' => string '' (length=0)
      '商城主页' => string '' (length=0)



	/**
	 * 商城底部菜单
	 */
	public function bottom(){
		$map["status"]="1";
		$map["praent_id"]="0";
		$praent_data=M("wx_shop_menu")->where($map)->select();
		$shop_menu_data=array();
		foreach ($praent_data as $key => $val){
			$shop_menu_data[$val['menu_name']]=$this->menu_childs($val['id']);
		}
		$this->assign("shop_menu_data",$shop_menu_data);
		$this->display();
	}
	/**
	 * 获取子类
	 */
	public function menu_childs($praent_id){
		$map["praent_id"] = $praent_id;
		$data = M("wx_shop_menu")->where($map)->select();
		$childs_data = array();
		foreach ($data as $key => $val){
			$childs_data[$val['menu_name']] = $val['url'];
		}
		return $childs_data;
		
	}

<!--index.html前端--->

<include file="./Application/Home/View/Shop/bottom.html" shop_menu_data="{$shop_menu_data}" />

<!--butoom.html-->

 



<div id="menu" >
<ul >

<notempty name="shop_menu_data">
<volist name="shop_menu_data" id="vo">

<li>
<img class="img_front" src="__PUBLIC__/wx_shop/images/front.png" />
<div class="menu_li">
<img src="__PUBLIC__/wx_shop/images/coin.png" width="10" />&nbsp;{$key}
</div>
<img class="line" src="__PUBLIC__/wx_shop/images/line.png" width="1" />
<span style="">
<img src="__PUBLIC__/wx_shop/images/navbg4.png" width="100%" />
<div >
<volist name="vo" id="child">
<a href="{$child}">{$key}</a>
</volist>
</div>
</span>
</li>
</volist>
</notempty>



</ul>
</div>
</body>
</html>

<!--menu.js必须写在后面-->
<script src="__PUBLIC__/wx_shop/js/menu.js" type="text/javascript"></script>

  

转载于:https://www.cnblogs.com/hgj123/p/4720520.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值