日期:2014-05-17 浏览次数:20443 次
foreach(array_chunk($arr1,4) as $v){ echo "<tr>\n"; foreach($v as $t) echo "<td>".$t."</td>\n"; echo "</tr>\n"; };
------解决方案--------------------
$arr1=array("a","b","c","d","e","f","g");
$i = 1;
echo '<tr>';
foreach ($arr1 as $key=>$val)
{
echo '<td>' , $val, '</td>';
if($i%4 == 0) echo "</tr><tr>";
++$i;
}
echo '</tr>';