总数21,分成5份,每一份输出5条 怎么写

WBOY
Release: 2016-06-23 14:17:15
Original
935 people have browsed it

我用php 做模版
总共调用21个标题  分成5份输出,每一份的样式不同,请问判断怎么写?
--------大致效果如下-----------
               
                    一个H2标题
           
显示5个标题              显示5个标题
           
显示5个标题              显示5个标题
--------大致效果如上-----------
请给出代码


回复讨论(解决方案)

做模板? 直接用smarty...可以秒杀你的问题

测试代码

//模拟数据$ar = range(1, 21);//按要求切割$t = array_merge(  array(array(array_shift($ar))) //第一份数据  , array_chunk($ar, count($ar)/4) //剩余的分成4分);//输出foreach($t as $i=>$r) {  echo "<div id=y$i>". join('<br>', $r) . "</div>\n";}
Copy after login

1

2
3
4
5
6

7
8
9
10
11

12
13
14
15
16

17
18
19
20
21

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