There are a few parts to this code. The first part is creating fixtures.
$totalRounds = $teams - 1;
$matchesPerRound = $teams / 2;
$rounds = array();
$roundDates = array();
$curTime = time();
for ($i = 0; $i < $totalRounds; $i++) {
$rounds[$i] = array();
$numDays = $i * 4;
$roundDates[$i] = strtotime("+".$numDays." days",$curTime);
}
foreach($roundDates as $time) {
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]~$time";
}
}
}
In the above code, a time is made for each round of fixtures. At the end of the code I have added $time.
for ($i = 0; $i < count($rounds); $i++)
{
foreach ($rounds[$i] as $r)
{
$seperateUsers = explode("@",$r);
$homeinfo = $seperateUsers[0];
$awayinfo = $seperateUsers[1];
$homedetails = explode("~",$homeinfo);
$awaydetails = explode("~",$awayinfo);
$database->addFixtures($homedetails[0], $homedetails[1], $awaydetails[0], $awaydetails[1], $awaydetails[2]);
}
}
This piece of code uses breaks down the code from above to put into the table. For some reason, the date that is being entered into the database comes out 0000-00-00 00:00:00.
Is there anything anyone can see to fix this?
Edit: the loop isnt working? Am i missing anything on the actual loop?