您的位置:首页 > 其它

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

2015-08-11 11:32 381 查看
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" /> {$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>

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: