PDA

View Full Version : Fixture List



kpw81
10-29-2008, 04:08 PM
I want to create a script to generate a list of fixtures for 14 teams in a league competition. each team will play every other team twice, once at home, once away from home. is there anyone who can help me do this?

the only code i have right now is:

<?
$teams = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);

foreach ($teams as $homer) {
foreach ($teams as $guest) {
if ($homer == $guest)
continue;

echo "$homer v $guest<br>";
}
}
?>

this creates all of the pairings, but in no particular order. how can i get it to put them into some sort of order so that teams do not play more than one game each week?

pghcollectibles
11-01-2008, 11:49 AM
i understand what your saying but i think im getting a mind blank...

have $homer and $guest been assigned values yet?

this is happening over 26 weeks? (each team would play 26 times)
with 7 games played each week?

kpw81
11-02-2008, 05:27 AM
you're right, 7 games per week for 26 weeks.

The $homer/$guest variables get their values from the $teams array which is set in the first line of code.

hope that makes it a little clearer.

pghcollectibles
11-04-2008, 06:29 AM
sorry it took so long... ive been working on this in my sparse free time. here is the code. double, triple checked. it outputs away team @ home team to understand where your playing and all that too.



<?
$teams = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
$homer=$teams;
$guest=$teams;
$day=0;
$week=0;
$h=1;
while ($week<14) {
$weekout=$week+1;
$fixture.="Week---{$weekout}<br />";
if (($weekout/2)==(int)($weekout/2)){
$g=1;
}else{
$g=0;
}
while ($day<7){
if ($h==14){
$h=0;
}else if ($h==15){
$h=1;
}
$fixture.="{$guest[$g]}&nbsp;@&nbsp;{$homer[$h]}<br />";
$g=$g+2;
if ($g==14){
$g=0;
}else if ($g==15){
$g=1;
}
$h=$h+2;
$day++;
}
$day=0;
$week++;
$h=$week+1;
}
$day=0;
$week=14;
$h=2;
while ($week<26) {
$weekout=$week+1;
$fixture.="Week---{$weekout}<br />";
if (($weekout/2)==(int)($weekout/2)){
$g=7;
}else{
$g=0;
}
while ($day<7){
if ($h==14){
$h=0;
} else if ($h==15){
$h=1;
}
$fixture.="{$guest[$g]}&nbsp;@&nbsp;{$homer[$h]}<br />";
$g++;
if ($g==14){
$g=0;
}
$h++;
$day++;
}
$day=0;
$week++;
if (($week/2)!=(int)($week/2)){
$h++;
}
}

echo $fixture;
?>


the $teams array can be filled in with the names of each team ie:

$teams=array("team1","team2","team3","team4","team5","team6","team7","team8","team9","team10","team11","team12","team13","team14");

kpw81
11-04-2008, 08:58 AM
thank you very much for the help, i've been struggling with this for months with no real progress.

i've tried out the code, and it mostly works fine, but there is one small problem and i can't find it in the code.

if i take team 1 as the example, and look at their fixtures, they start with an away game at team 2, and play an away game every other week with the team number going up by 2 each time "e.g. week 3 @ team 4, week 5 @ team 6...) whilst in between they play a home game against the same teams but in reverse (e.g. week 2 against team 14, week 4 against team 12, week 6 against team 10...).

but in the second half of the season, rather than the team number of the opponents changing by 2, it only changes by 1, meaning that there are some duplicate fixtures and some that never happen.

once again, thanks for putting in the time to help me get this far, and any help in getting rid of this last little bug would be much apreciated.

thank you

pghcollectibles
11-04-2008, 11:09 AM
i must have screwed it up when i fixed the last problem. ill try to get to it today but im not sure if ill have time

pghcollectibles
11-04-2008, 11:48 AM
ive got something in mind using rand() and setting arrays to follow the rules

pghcollectibles
11-05-2008, 09:24 PM
ok i got it... sort of.

im sure this code would work but i end up getting errors from the script taking longer than 30 seconds to execute

i have inserted two resets in the code, one for time and one for number of tries to try to fit in the right numbers.

maybe the problem is random is so random that its not systematically random in picking every combination at least once

the numbers started taking around 0.00065 seconds and i started number of times at 10 to run the loop now i have it at 0.5 seconds and 100000 tries to find the right number and once its not possible because the numbers were not put in the right spots it wouldnt really matter how many chances i give it. i guess ill try running it more with smaller numbers, like 196 tries (the number of possible combinations) but here is the code. i see nothing wrong with it now except its not getting the entire fixture. once it works, my plan was to use:

$fixture .= ... then echo $fixture at the end.

instead of

echo "



<?
$teamname = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
$blank = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0);
$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];
function getteam(){
$t=rand(0,13);
return $t;
}
function reset_games(){
global $i,$day,$week,$played,$blank,$homer,$guest,$trys;
$i=0;
$day=0;
$week=0;
$played=$blank;//keeps track if the team has played that week
while ($i<14){
$homer[$i]=$blank;
$guest[$i]=$blank;
$i++;
}
$trys=0;
}
reset_games();
while ($week<26){
$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
$ttime=$etimer-$stimer;
if ($ttime>0.5){
echo "too long, ressetting...<br />";
reset_games();
}
$weekout=$week+1;
echo "Week&nbsp;{$weekout}---<br />";
$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];
while ($day<7){
$g=getteam();
$h=getteam();
if ($g!=$h && $homer[$h][$g]==0 && $guest[$g][$h]==0 && $played[$g]==0 && $played[$h]==0){
$homer[$h][$g]=1;
$guest[$g][$h]=1;
$played[$g]=1;
$played[$h]=1;
echo "&nbsp;&nbsp;{$teamname[$g]}&nbsp;@&nbsp;{$teamname[$h]}<br />";
$day++;
$trys=0;
}else{
$trys++;
}
if ($trys==100000){
echo "too many, resetting...<br />Week 1---<br/>";
reset_games();
}
}
$day=0;
$week++;
$played=$blank;
}
?>

pghcollectibles
11-05-2008, 09:55 PM
ok i added this to the very beginning:


$longest=0;and changed this:
if ($trys==100000){
echo "too many, resetting...<br />Week 1---<br/>";
reset_games();
}
to this:
if ($trys==196){
if ($longest<=$week){
$longest=$week;
}
$longestout=$longest+1;
echo "too many, resetting... Longest run: {$longestout} weeks<br />Week 1---<br/>";
reset_games();
}
the longest run i have made:18 weeks :( and here i am thinking math is cool this should be a fun project... ha

kpw81
11-07-2008, 09:06 AM
thanks for your help so far, it's much apreciated. i've been having a good think about this over the last couple of days and i think i've realised why it's proving to be so difficult.

the logical way of doing this is similar to what you attempted in your first piece of code, where for the first 14 weeks, odd numbered teams play home and away to the even numbered teams, but when it comes to creating the rest of the fixtures, you can't have a full set of fixtures consisting of ties between 2 even numbered teams and 2 odd numbered teams as there is an odd number of each, after the first 6 ties are created there will be one odd and one even team remaining, but no matter which teams they are, they will have played each other twice already in the first 14 weeks.

as a result, i've been doing some more thinking about possible solutions. although not ideal, and requiring some changes to be made to the rest of my website, i've decided to alter the league structure so that each league contains a number of teams divisible by 4 so that i can match up odd numbered teams and even numbered teams in pairs for the second half of the season.

i've gone back to the original code and altered the first part of it to create fixtures for 16 teams, which creates the first 16 weeks worth of fixtures.

now, logic suggests that if i match up the teams (odds vs odds and evens vs evens) then the rest of the fixtures should be easy to create, but i'm not exactly sure how to code this.

there are 2 possible ways i can think of, one being to split the current array into 2, one for odd numbered teams, one for evens) and create the fixtures between those teams using a similar loop as used in the first 16 weeks, but i'm not sure how to do this using 2 arrays without having the code repeating several times through the script. the second solution would be to somehow only match up teams from the existing array so that only evens play evens and odds play odds.

does that make any sense? is there any way you can help me create this code. i apreciate the amount of time and work you have put in already, and would be extremely greatful if you could help me (hopefully) complete the code. the code i have is as follows.


<?
$teams = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
$homer=$teams;
$guest=$teams;
$day=0;
$week=0;
$h=1;
while ($week<16) {
$weekout=$week+1;
$fixture.="Week---{$weekout}<br />";
if (($weekout/2)==(int)($weekout/2)){
$g=1;
}else{
$g=0;
}
while ($day<8){
if ($h==16){
$h=0;
}else if ($h==17){
$h=1;
}
$fixture.="{$guest[$g]}&nbsp;@&nbsp;{$homer[$h]}<br />";
$g=$g+2;
if ($g==16){
$g=0;
}else if ($g==17){
$g=1;
}
$h=$h+2;
$day++;
}
$day=0;
$week++;
$h=$week+1;
}
echo $fixture;
?>

thsnk you

pghcollectibles
11-07-2008, 11:10 AM
hold on... 8 days a week? sounds like a beatles song. will there now be 240 games?
8 games/wk for 30 weeks? same rules 1 game/week/team every team plays every other team once at home and once away. ill change $day to $game for easier understanding of the code if so. i think this definitely sounds plausible.

kpw81
11-30-2008, 03:01 PM
i'm starting to feel like i'm banging my head against a brick wall, so frustrating. it seems like it should be so simple to generate a fixture list, but i've still not got it. is there anyone who can help. I understand it's a big job, but i really need this now to be able to make any more progress on my website.

Please can somebody help?

thanks

sjlplat
11-30-2008, 06:55 PM
I'm not sure I understand what you're trying to do here. You have 16 teams and you want to set up a game schedule to organize matches between each team twice per season?

kpw81
12-01-2008, 07:17 AM
I'm not sure I understand what you're trying to do here. You have 16 teams and you want to set up a game schedule to organize matches between each team twice per season?


yes

ideally i would like it with just 14 teams, but from a maths point of view i thought it would be easier to do with 16, so 16 teams is fine, but 14 teams would be preferred.

even if you're unsure of how to code it in php, any help in terms of the logic of how i could do this would be much apreciated.

shadmego
12-01-2008, 07:43 AM
I spent a couple hours on this last night and I am not fully sure I understand what is going on either. I did not get near where your last bit of code is but I think I might be able to follow some logic.

Your last posted code is able to list games properly for odd numbered teams playing even numbered teams at home and away. It does not however, list games to be played between odd or even numbered teams.

What I mean is Team 1 is able to play Teams 2, 4, 6, 8, 10, 12, 14 or 16 using your script, but Team 1 does not have a schedule for Teams 3, 5, 7, 9, 11, 13 or 15. Likewise, Team 2 does not have a schedule for even numbered teams.

Instead of thinking linearly, you may have to use the ability of php to use classes and other objects. Either each team or each game (which might be better) should be it's own class. You shouldn't have to make a class for each team, but make a class or function that creates the matches themselves.

Schedule creation is actually something of a complex thing. You have to be able to tell if a team has already played another team, not matter where they fall in the game (home or away, position 1 or position 2).

The script is going to have to be able to tell if a pairing has already occurred, and possibly how it occurred as well. For instance, if for team 1, the schedule 1 @ 16 was created, then the script will have to know this when it creates the next pairing, 16 @ 1.

It sounds easy on the surface, and writing out a paper schedule might work as well, but figuring out the step-by-step process your brain is going through and translating that to logical code is another matter altogether.

So each pairing, being the result of some function, or class with a set of functions, needs to be checked each time it is run for pairings that have already occurred and if they have happened, the script needs to discard them, or manipulate the pairing to suit the schedule for each team.

But that isn't all. On top of figuring out all this, you have to make sure a team isn't slated to play two teams in one weekend. The schedule 1 @ 2 is fine, but later in the list, if 14 @ 1 happens on the same weekend, you have problems. Where does Team 1 go? Whom do they play?

So for each week, you need 16 numbers, not repeated at all. That is 8 games each week, or 7 games if using 14 teams.

Are you seeing how complicated this is getting?

The way I see it, you can create the schedule per week, or you can create the schedules per team, which might be easier, but either way, a weekly schedule and/or a team schedule might be better suited in its own function/class.

The reason I am pointing you in the direction of classes and functions is because it helps clean the code up a bit, reduces overhead, and allows you to interact with the functions/classes in the manner which I am thinking you need. So in the simplest way it might work, you will need a function that creates the actual pairing (1 - 16, 3 - 5, etc). Your script can then parse the function getting rid of each illogical pairing like 1 - 1.

You then need to create another function that takes these pairings as input and outputs the weekly/team schedule, making sure Team 1 isn't playing both Team 2 away and Team 13 in the same week. You will then need to also check to make sure teams are not playing each other more than twice a season, unless you want a playoff schedule as well, but then you need a ranking system, which is another headache best saved for another thread.

~regards, and good luck with this. My php chops are definitely not this advanced.

sjlplat
12-01-2008, 12:07 PM
Here's a working script. This one applies to a pair of divisions. I will need to work on it further if you want all teams to be matched against one another.


<?php

for ($x = 1; $x <= 2; $x++) {
for ($w = 1; $w <= 7; $w++) {
if ($x == 1) {
$week = $w;
}
else {
$week = $w + 7;
}
echo "<table><tr><th colspan=\"2\">Week $week</th></tr>";
echo "<tr><th>Home</th><th>Visitor</th></tr>";
$h = $w;
$v = (15 - $h) + ($w - 1);
for ($g = 1; $g <= 7; $g++) {
if ($x == 1) {
echo "<tr><td>Team $h</td><td>Team $v</td></tr>";
}
else {
echo "<tr><td>Team $v</td><td>Team $h</td></tr>";
}
$h++;
if ($h > 7) {
$v = $w - ($h - 7);
}
else {
$v--;
}
}
echo "</table>";
}
}

?>

pghcollectibles
12-01-2008, 02:50 PM
the original rules of the "challenge" were:

14 teams
each team plays one time per week
each team plays every other team once at home and once away

so with 13 other teams each team plays 26 times

then the math seemed impossible so the question was to change the number of teams playing to 16

on a flip side of that i wonder if adding a bye week or two might help. other than adding more hassle to the code it would extend the maximum possibilities and maybe make the math work but it would affect the number of weeks. with two bye games there would be 28 weeks...

id have to plug in the numbers but it's worth a thought

sjlplat
12-01-2008, 10:29 PM
Here's a function to build all your pairings and put them in individual arrays. From here it's a matter of building a schedule and checking the arrays. My brain's shot -- This is about as far as I can get with it right now.


<?php

function build_array($x) {
for ($h = 1; $h <= 14; $h++) {
for ($v = 1; $v <= 14; $v++) {
if ($v != $h && $x == $h) {
$t{$x}[] = $v;
}
}
}
return $t{$x};
}

for ($a = 1; $a <= 28; $a++) {
$t{$a} = build_array($a);
}

?>

sjlplat
12-02-2008, 07:48 AM
Well, here's a working script. It's not pretty but it seems to get the job done. Demo at http://www.boogerwelds.com/test/schedule.php


<?php
function day($z) {
switch ($z) {
case 1:
return "Sunday";
break;
case 2:
return "Monday";
break;
case 3:
return "Tuesday";
break;
case 4:
return "Wednesday";
break;
case 5:
return "Thursday";
break;
case 6:
return "Friday";
break;
case 7:
return "Saturday";
break;
}
}
$hs = 8;
$vs = 7;
$sw = 1;
for ($x = 1; $x <= 15; $x++) {
for ($w = $sw; $w <= $sw; $w++) {
if ($hs > 15) {
$hs = 1;
}
if ($vs > 15) {
$vs = 1;
}
$h = $hs;
$v = $vs;
echo "<h1>Week $w</h1>";
echo "<table><tr><th></th><th>Home</th><th>Visitor</th></tr>";
for ($d = 1; $d <= 7; $d++) {
$day = day($d);
if ($h > 15) {
$h = 1;
}
if ($h == 15) {
echo "<tr><td style=\"font-weight:bold\">$day</td><td>--</td>";
}
else {
echo "<tr><td style=\"font-weight:bold\">$day</td><td>Team $h</td>";
}
$h++;
if ($v < 1) {
$v = 15;
}
if ($v == 15) {
echo "<td>--</td></tr>";
}
else {
echo "<td>Team $v</td></tr>";
}
$v--;
}
echo "</table>";
$hs++;
}
$sw++;
for ($w = $sw; $w <= $sw; $w++) {
if ($hs > 15) {
$hs = 1;
}
if ($vs > 15) {
$vs = 1;
}
$h = $hs;
$v = $vs;
echo "<h1>Week $w</h1>";
echo "<table><tr><th></th><th>Home</th><th>Visitor</th></tr>";
for ($d = 1; $d <= 7; $d++) {
$day = day($d);
if ($h > 15) {
$h = 1;
}
if ($h == 15) {
echo "<tr><td style=\"font-weight:bold\">$day</td><td>--</td>";
}
else {
echo "<tr><td style=\"font-weight:bold\">$day</td><td>Team $h</td>";
}
$h++;
if ($v < 1) {
$v = 15;
}
if ($v == 15) {
echo "<td>--</td></tr>";
}
else {
echo "<td>Team $v</td></tr>";
}
$v--;
}
echo "</table>";
$vs++;
}
$sw++;
}
?>

happycamper
02-13-2009, 03:29 PM
Hi gents,

I am looking for a schedule script similar to the above...

games played (mon, tue, thu, fri) 4 games a week

20 Teams each playing each other twice home and away per season

total of 38 games per season

I have no clue how to do this, and would be open to any idea's :confused:

Thanks

happycamper
02-15-2009, 06:43 PM
Found this and worked for me :)


<?php

function main() {
?>
<style>
input, textarea { display: block; margin-bottom: 1em; }
label { font-weight: bold; display: block; }
</style>
<h1>Fixtures Generator</h1>
<?php
// Find out how many teams we want fixtures for.
if (! isset($_GET['teams']) && ! isset($_GET['names'])) {
print get_form();
} else {
# XXX check for int
print show_fixtures(isset($_GET['teams']) ? nums(intval($_GET['teams'])) : explode("\n", trim($_GET['names'])));
}
}

function nums($n) {
$ns = array();
for ($i = 1; $i <= $n; $i++) {
$ns[] = $i;
}
return $ns;
}

function show_fixtures($names) {
$teams = sizeof($names);

print "<p>Fixtures for $teams teams.</p>";

// If odd number of teams add a "ghost".
$ghost = false;
if ($teams % 2 == 1) {
$teams++;
$ghost = true;
}

// Generate the fixtures using the cyclic algorithm.
$totalRounds = $teams - 1;
$matchesPerRound = $teams / 2;
$rounds = array();
for ($i = 0; $i < $totalRounds; $i++) {
$rounds[$i] = array();
}

for ($round = 0; $round < $totalRounds; $round++) {
for ($match = 0; $match < $matchesPerRound; $match++) {
$home = ($round + $match) % ($teams - 1);
$away = ($teams - 1 - $match + $round) % ($teams - 1);
// Last team stays in the same place while the others
// rotate around it.
if ($match == 0) {
$away = $teams - 1;
}
$rounds[$round][$match] = team_name($home + 1, $names)
. " v " . team_name($away + 1, $names);
}
}

// Interleave so that home and away games are fairly evenly dispersed.
$interleaved = array();
for ($i = 0; $i < $totalRounds; $i++) {
$interleaved[$i] = array();
}

$evn = 0;
$odd = ($teams / 2);
for ($i = 0; $i < sizeof($rounds); $i++) {
if ($i % 2 == 0) {
$interleaved[$i] = $rounds[$evn++];
} else {
$interleaved[$i] = $rounds[$odd++];
}
}

$rounds = $interleaved;

// Last team can't be away for every game so flip them
// to home on odd rounds.
for ($round = 0; $round < sizeof($rounds); $round++) {
if ($round % 2 == 1) {
$rounds[$round][0] = flip($rounds[$round][0]);
}
}

// Display the fixtures
for ($i = 0; $i < sizeof($rounds); $i++) {
print "<p>Round " . ($i + 1) . "</p>\n";
foreach ($rounds[$i] as $r) {
print $r . "<br />";
}
print "<br />";
}
print "<p>Second half is mirror of first half</p>";
$round_counter = sizeof($rounds) + 1;
for ($i = sizeof($rounds) - 1; $i >= 0; $i--) {
print "<p>Round " . $round_counter . "</p>\n";
$round_counter += 1;
foreach ($rounds[$i] as $r) {
print flip($r) . "<br />";
}
print "<br />";
}
print "<br />";

if ($ghost) {
print "Matches against team " . $teams . " are byes.";
}
}

function flip($match) {
$components = split(' v ', $match);
return $components[1] . " v " . $components[0];
}

function team_name($num, $names) {
$i = $num - 1;
if (sizeof($names) > $i && strlen(trim($names[$i])) > 0) {
return trim($names[$i]);
} else {
return $num;
}
}

function get_form() {
$s = '';
$s = '<p>Enter number of teams OR team names</p>' . "\n";
$s .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '">' . "\n";
$s .= '<label for="teams">Number of Teams</label><input type="text" name="teams" />' . "\n";
$s .= '<input type="submit" value="Generate Fixtures" />' . "\n";
$s .= '</form>' . "\n";

$s .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '">' . "\n";
$s .= '<div><strong>OR</strong></div>' . "\n";
$s .= '<label for="names">Names of Teams (one per line)</label>'
. '<textarea name="names" rows="8" cols="40"></textarea>' . "\n";
$s .= '<input type="submit" value="Generate Fixtures" />' . "\n";
$s .= "</form>\n";
return $s;
}

main();

?>

happycamper
02-17-2009, 02:39 AM
Now at this stage, this pulls teams from the database and builds the matches. All I have to do now is insert the fixtures back to the database :)


<?php

// CONNECTING TO DATABASE
$dbhost = 'localhost';
$dbuser = '********';
$dbpass = '*******';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = '**********';
mysql_select_db($dbname);

$table = "eden_prem";
$sql = "SELECT * FROM $table";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$names[] = $row['team_name'];
$ids[] = $row['id'];
}

mysql_free_result($result);
echo show_fixtures($names,$ids);

function nums($n) {
$ns = array();
for ($i = 1; $i <= $n; $i++) {
$ns[] = $i;
}
return $ns;
}

function show_fixtures($names,$ids) {
$teams = sizeof($names);

print "<p>Fixtures for $teams teams.</p>";

// If odd number of teams add a "ghost".
$ghost = false;
if ($teams % 2 == 1) {
$teams++;
$ghost = true;
}

// Generate the fixtures using the cyclic algorithm.
$totalRounds = $teams - 1;
$matchesPerRound = $teams / 2;
$rounds = array();
for ($i = 0; $i < $totalRounds; $i++) {
$rounds[$i] = array();
}

for ($round = 0; $round < $totalRounds; $round++) {
for ($match = 0; $match < $matchesPerRound; $match++) {
$home = ($round + $match) % ($teams - 1);
$away = ($teams - 1 - $match + $round) % ($teams - 1);
// Last team stays in the same place while the others
// rotate around it.
if ($match == 0) {
$away = $teams - 1;
}
$rounds[$round][$match] = team_name($home + 1, $names)
. " v " . team_name($away + 1, $names);
}
}

// Interleave so that home and away games are fairly evenly dispersed.
$interleaved = array();
for ($i = 0; $i < $totalRounds; $i++) {
$interleaved[$i] = array();
}

$evn = 0;
$odd = ($teams / 2);
for ($i = 0; $i < sizeof($rounds); $i++) {
if ($i % 2 == 0) {
$interleaved[$i] = $rounds[$evn++];
} else {
$interleaved[$i] = $rounds[$odd++];
}
}

$rounds = $interleaved;

// Last team can't be away for every game so flip them
// to home on odd rounds.
for ($round = 0; $round < sizeof($rounds); $round++) {
if ($round % 2 == 1) {
$rounds[$round][0] = flip($rounds[$round][0]);
}
}

// Display the fixtures
for ($i = 0; $i < sizeof($rounds); $i++) {
print "<p>Match " . ($i + 1) . "</p>\n";
foreach ($rounds[$i] as $r) {
print $r . "<br />";
}
print "<br />";
}
print "<p>Second half is mirror of first half</p>";
$round_counter = sizeof($rounds) + 1;
for ($i = sizeof($rounds) - 1; $i >= 0; $i--) {
print "<p>Match " . $round_counter . "</p>\n";
$round_counter += 1;
foreach ($rounds[$i] as $r) {
print flip($r) . "<br />";
}
print "<br />";
}
print "<br />";

if ($ghost) {
print "Matches against team " . $teams . " are byes.";
}
}

function flip($match) {
$components = split(' v ', $match);
return $components[1] . " v " . $components[0];
}

function team_name($num, $names) {
$i = $num - 1;
if (sizeof($names) > $i && strlen(trim($names[$i])) > 0) {
return trim($names[$i]);
} else {
return $num;
}
}

?>

kpw81
02-18-2009, 12:03 PM
hello everyone,

been busy over the last couple of months, so this has had to be put on hold temporarily, but i'm back now able to give it my full attention.

just wanted to say thanks for all the updates since my last post, and i'll have a look through them to see if they will work for me. will post later to let you know how it goes.

once again, thanks for the help, it's really apreciated.