PHP隔行换色输出几行几列表格。

<?php
$table = '';
function PrintTable($rows, $cols)
{
global $table;
$table .= "<table width='700' border='1'>";
for ($i=1;$i<$rows;$i++) {
$color = $i % 2 == 0 ? 'green' : 'orange';
$table .= "<tr bgcolor='$color'>";
for ($j=1;$j<$cols;$j++) {
$table .="<td>xxoo</td>";
}
$table .= "</tr>";
}
$table .= "</table>";
return $table;
}
echo PrintTable(10, 10);
?>
posted @ 2018-09-16 19:07  程序-猿猿  阅读(1348)  评论(0编辑  收藏  举报