<table width="100%" border="0" cellspacing="1" cellpadding="0" style="background:#ccc">
<tr>
<td align="center" bgcolor="#ffffff">第一列</td>
<td align="center" bgcolor="#ffffff">第二列</td>
</tr>
<tr>
<?php
$setarr = array(0,1,2,3,4,5,6,7,8,9); //相当于数据库获取的数组
$i=0;
foreach($setarr as $val){
$i++;
?>
<?=$val?>
<?php
if($i%2==0&&$i<count($setarr)) echo '</tr><tr>';
} ?>
</tr>
</table>
如:是其他字符类型,需要用到函数转化:
<?php
$str = "hello world. it's a beautiful day.";
print_r (explode(" ",$str));
?>
结果:
array
(
[0] => hello
[1] => world.
[2] => it's
[3] => a
[4] => beautiful
[5] => day.
)
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!