foreach循环中,这样的变化怎么写

WBOY
Release: 2016-06-13 12:08:13
Original
827 people have browsed it

foreach循环中,这样的变化如何写

本帖最后由 albb_num1 于 2014-10-19 21:34:12 编辑 输出的内容一样的,只是样式不一样,
第一个输出
题目1  
第二个输出
题目2|(没有标签了且后面跟有|
以此类推
我只写出了第一个,第二个不会写了,我也知道要用判断,但不知怎么写

<?php if(!empty($output['navigation_list']) && is_array($output['navigation_list'])) {?><br />      <?php foreach($output['navigation_list'] as $value) {?><br />      <?php if($value['navigation_id']>11 && $value['navigation_id']<27){?><br />      <strong><a href="#">题目1</a></strong> <br />      <?php } ?><br />      <?php } ?><br />      <?php } ?>
Copy after login

------解决思路----------------------
可以简单的参考下:
$array = array(1,2,3,4,5,6,7,8,9,10);<br />        $num=1;<br />        foreach ($array as $key => $value) {<br />            if($num%2==0){<br />                echo '<strong><a href="#">题目'.$value.'</a></strong><span><br><font color='#FF8000'>------解决思路----------------------</font><br></span>';<br />            }else{<br />                echo '<strong><a href="#">题目'.$value.'</a></strong>  ';<br />            }<br />            $num++;<br />        }
Copy after login

效果图为:
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template