Here's my code:
$totalRounds = 1;
$teams = array('Team 1', 'Team 2', 'Team 3', 'Team 4', 'Team 5');
echo 'Total Teams: ' , $totalTeams = count($teams) , '<br/>';
$turns = $totalTeams;
for($round=1; $round<$totalRounds+1; $round++){
echo 'Round: ' , $round , '<br/>';
for($homeTeam=0; $homeTeam<$totalTeams-1; $homeTeam++){
for($awayTeam=0; $awayTeam<$totalTeams; $awayTeam++){
if($teams[$homeTeam] != $teams[$awayTeam]){
echo $teams[$homeTeam] , ' v/s ' , $teams[$awayTeam] , '<br/>';
}
}
unset($teams[$homeTeam]);
}
echo '<br/>';
}
My expected output is:
Team 1 v/s Team 2 <br/>
Team 1 v/s Team 3 <br/>
Team 1 v/s Team 4 <br/>
Team 1 v/s Team 5 <br/>
Team 2 v/s Team 3 <br/>
Team 2 v/s Team 4 <br/>
Team 2 v/s Team 5 <br/>
Team 3 v/s Team 4 <br/>
Team 3 v/s Team 5 <br/>
Team 4 v/s Team 5 <br/>
My actual output is giving me undefined index errors
Once this is fixed I don't know how to assign home and away teams. Eg. Team 1 should have only 2 home games, instead it has 4. Each team will play 2 home games and 2 away games.