首頁  >  文章  >  後端開發  >  怎么循环带条件的数组

怎么循环带条件的数组

WBOY
WBOY原創
2016-06-13 12:08:061000瀏覽

如何循环带条件的数组

本帖最后由 albb_num1 于 2014-10-18 20:47:12 编辑 下面这个数组

<br />$abc=array(     <br />[navigation_list] => Array<br />        (<br />            [0] => Array<br />                (<br />                    [navigation_id] => 1<br />                    [navigation_title] => 题目1<br />                    [navigation_link] => http://127.0.0.1/<br />                    [navigation_sort] => 255<br />                    [navigation_open_type] => 1<br />                )<br /><br />            [1] => Array<br />                (<br />                    [navigation_id] => 2<br />                    [navigation_title] => 题目2<br />                    [navigation_link] => http://127.0.0.1/circle<br />                    [navigation_sort] => 255<br />                    [navigation_open_type] => 1<br />                )<br /><br />            [2] => Array<br />                (<br />                    [navigation_id] => 3<br />                    [navigation_title] => 题目3<br />                    [navigation_link] => http://127.0.0.1/microshop<br />                    [navigation_sort] => 255<br />                    [navigation_open_type] => 1<br />                )<br /><br />            [3] => Array<br />                (<br />                    [navigation_id] => 4<br />                    [navigation_title] => 题目4<br />                    [navigation_link] => http://127.0.0.1/shop/index.php?act=brand<br />                    [navigation_sort] => 255<br />                    [navigation_open_type] => 1<br />                )<br /><br />        )<br />)<br />

如果我想循环出后面二个数组,即前面两个不要,怎么写条件呢
下面代码是我写的,为啥循环不出来呢,哪里错了:
<br /><?php <br />      <br />      if ($abct[navigation_list][navigation_id]>2 || $output[navigation_list][navigation_id]>5){<br />      foreach($output['navigation_list'] as $value) {?><br />      <li class="link"><a href="<?php echo $value['navigation_link'];?>" <?php echo $value['navigation_open_type']=='1'?'target="_blank"':'';?>><?php echo $value['navigation_title'] ?></a></li><br />      <?php } ?><br />      <?php }?><br />

------解决思路----------------------
<?php <br />      foreach($abc['navigation_list'] as $value) {?><br><?php  if ($value['navigation_id']>2){ ?>     <div class="clear">
                 
              
              
        
            </div>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn