tags:

views:

23

answers:

2

I have created a fixture generator for football/ soccer games...

    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] = "$user[$home]~$team[$home]@$user[$away]~$team[$away]~$roundDates[$round]";
        }
    }

I am altering the question as I am almost there.

$roundDates[$round]

This piece of code, i need $round-1. What is the correct syntax for this? Cheers

A: 

Create the date with maketime(), it takes number of days as 5th argument.

$date = time() + maketime(NULL, NULL, NULL, NULL, $i);
Mikulas Dite
A: 

you want the first date 4 days from now

translates to + 4 (not * 4)

This should also make it more clear why $i should be zero-based:

for ($i=0; $i<$totalRounds; $i++)
webbiedave