<?php

/**

*绘制一个表格

*@author wss

*@param $width 表格的宽

*@param $height 表格的高

*/

function drawTable($width,$height){

echo "<table style='color:#fff'>";

for ($i=0; $i<$height; $i++) {

if($i%2==0){

echo "<tr style='background:red'>";

}else{

echo "<tr style='background:green'>";

}

for ($j=$i*$width; $j<($i+1)*$width; $j++) {

echo "<td>";

echo $j;

echo "</td>";

}

echo "</tr>";

}

echo "</table>";

}

drawTable(10,5)

?>



<?php

function drawtable($width,$height){

echo"您要绘制的是".$width."行".$height."列的表格<br/>";

echo"<table style='color:#fff;'>";

for($i=0;$i<$width;$i++){

if($i%2==0){

echo"<tr style='background-color:red;'>";

}else{

echo"<tr style='background-color:green;'>";

}

for($j=$i*$height;$j<($i+1)*$height;$j++){

echo"<td>";

echo$j;

echo"</td>";

}echo"</tr>";

}echo"</table>";

}drawtable(8,10);

?>