got to write a small script, that outputs matches in a league together with its matchday. got something to work but only for leagues that have a power of 2 members. problem is, i need something that works for virtually every number (8-20 players probably in fact). anyone got an idea, how to do this? i'll attach the code i put together, perhaps it helps in some way...
<?php
function matchtime($day){
return "time";
}
function setHSeason($teams, $day=0, $id=0){
if((count($teams)%2)!=0){
$teams[] = "dummy";
}
$i=$j=$k=0;
foreach($teams as $team){
($i++ < count($teams)/2)?$teamsA[$j++]=$team:$teamsB[$k++]=$team;
}
for($a=0; $a<$j; $a++){
for($b=0; $b<$j; $b++){
if(($b%2)!=0)
$match[$id++]=array('t1'=>$teamsA[$b],'t2'=>$teamsB[(($b+$a)%$j)],'time'=>matchtime($a+$day),'day'=>($a+$day+1));
else
$match[$id++]=array('t1'=>$teamsB[(($b+$a)%$j)],'t2'=>$teamsA[$b],'time'=>matchtime($a+$day),'day'=>($a+$day+1));
}
}
if($i > 2){
$match = array_merge($match, setHSeason($teamsA, $j+$day, $id));
$match = array_merge($match, setHSeason($teamsB, $j+$day, $id));
}
return $match;
}
//debug
$match=setHSeason(array('1','2','3','4','5','6','7','8', '9','10','11','12','13','14','15','16'));
echo '<table><tr><td>$spiel[id]<td>$spiel[t1]<td>$spiel[t2]<td>$spiel[time]<td>$spiel[day]';
foreach($match as $id => $spiel){
echo "<tr><td>$id<td>$spiel[t1]<td>$spiel[t2]<td>$spiel[time]<td>$spiel[day]</tr>";
}
echo "</table>";
?>