Quote:
Originally Posted by Fou-Lu
This has repetition in it.
|
It can be easily fixed:
PHP Code:
function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<$teams; $i++) {
$output .= '<tr>';
for($j=2; $j<=$teams; $j++) {
$output .= '<td>';
if($i >= $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}
print schedule();