生活随笔
收集整理的這篇文章主要介紹了
把一维数组处理成二维数组
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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>
總結
以上是生活随笔為你收集整理的把一维数组处理成二维数组的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。