An array with values 4 days apart
- by Luke
I have a piece of code that generates soccer/football fixtures.
The idea is that for every round of fixtures, the date will be 4 days further than the last round.
So round one will be 3rd may, round two will be 7th may, round three 11th may, etc.
I am not sure how to do this?
The code that currently makes the fixtures are as follows:
$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] = "$user[$home]~$team[$home]@$user[$away]~$team[$away]";
}
}
The teams would be the total users in the league.
So if there are 8 teams, there will be 7 rounds.
And i will want each round 4 days apart.
And that date will be within each fixture within each round.
Any further information needed just ask!
Thanks, really stuck on this