Adding a date every few days
- by Luke
I have some code that generates fixtures, I am looking to add a fixture date to the code.
$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]";
}
}
$team is the amount of teams in the league.
I want to add a variable for every 4 days, and for every round of fixtures generated, I want to add 4 days onto the previous round.
For example, if today is 3rd may, i want 3rd may for first fixture, 7th may for second fixture, 11th may for third fixture.
By fixture i mean round which includes a set of fixtures!