Rumah >pembangunan bahagian belakang >tutorial php >怎么循环带条件的数组

怎么循环带条件的数组

WBOY
WBOYasal
2016-06-13 12:08:061030semak imbas

如何循环带条件的数组

本帖最后由 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>
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn