首页 >后端开发 >php教程 >怎么循环带条件的数组

怎么循环带条件的数组

WBOY
WBOY原创
2016-06-13 12:08:061030浏览

如何循环带条件的数组

本帖最后由 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