View Single Post
Old 11-13-2012, 09:10 PM   PM User | #11
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
Quote:
Originally Posted by Fou-Lu View Post
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(); 
__________________
Ushousebuilders.com
poyzn is offline   Reply With Quote