php循环table实现一行两列显示的方法
<tablewidth="100%"border="0"cellspacing="1"cellpadding="0"style="background:#CCC">
<tr>
<tdalign="center"bgcolor="#FFFFFF">第一列</td>
<tdalign="center"bgcolor="#FFFFFF">第二列</td>
</tr>
<tr>
<?php
$setarr=array(0,1,2,3,4,5,6,7,8,9);//相当于数据库获取的数组
$i=0;
foreach($setarras$val){
$i++;
?>
<?=$val?>
<?php
if($i%2==0&&$i<count($setarr))echo'</tr><tr>';
}?>
</tr>
</table>
如:是其他字符类型,需要用到函数转化:
<?php
$str="Helloworld.It'sabeautifulday.";
print_r(explode("",$str));
?>
结果:
Array ( [0]=>Hello [1]=>world. [2]=>It's [3]=>a [4]=>beautiful [5]=>day. )
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短