function ajedrez($i, $j) {
if (($i + $j) % 2 == 0) {
return 'class="par"';
}
return '';
}
function tablero($tam = 8) {
?>
<table border="1">
<?php
for ($j = 0; $j < $tam; $j++) {
?>
<tr>
<?php
for ($i = 0; $i < $tam; $i++) {
?>
<td <?= ajedrez($i, $j) ?> ></td>
<?php }
?>
</tr>
<?php
}
?>
</table>
<?php
}
function creaTD($num, $cont) {
$res = "";
for ($i = 0; $i < $num; $i++) {
$res.="<td>" . ($cont++) . "</td>";
}
return $res;
}
function creaTR($num,$col,$cont){
$res = "";
for ($i = 0; $i < $num; $i++) {
$res.="<tr>" . creaTD($col, $cont) . "</tr>";
$cont+=$col;
}
return $res;
}