下面是个例子:表格横向排列例子:
<?php
$a = array (1,2,3,4,5,6,7,8,9,10,11);
$i = 0;
?>
<table border=1>
<tr>
<?
foreach ($a as $k){
if($i%3==0) {//该处表示需要横向排列的列数.
echo "</tr><tr>";
}
echo "<td>",$k,"</td>";//该处显示该列的数据.
$i ++;
}
?>
</tr>
</table>
下面是个例子:表格横向排列例子:
<?php
$a = array (1,2,3,4,5,6,7,8,9,10,11);
$i = 0;
?>
<table border=1>
<tr>
<?
foreach ($a as $k){
if($i%3==0) {//该处表示需要横向排列的列数.
echo "</tr><tr>";
}
echo "<td>",$k,"</td>";//该处显示该列的数据.
$i ++;
}
?>
</tr>
</table>