Foreach döngü zamanı değil çalışma

1 Cevap php

Bu kod için bir kaç parça vardır. İlk bölüm fikstür yaratıyor.

$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]);
        }   
    }

Bu kod parçası tabloya koymak için yukarıdaki kodu aşağı sonları kullanır. Nedense, veritabanına girilen ediliyor tarih 0000-00-00 00:00:00 çıkıyor.

Herkes bu düzeltmek görebilirsiniz bir şey var mı?

Edit: the loop isnt working? Am i missing anything on the actual loop?

1 Cevap

[0], vb $ homedetails benziyor ayarlanmamış. Sen addFixtures() çağırmadan önce bu değerleri incelemek için bir hata ayıklayıcı kullanabilirsiniz veya sağ çağrısından önce basit echo veya var_dump() ifadeleri ekleyerek onları incelemek olabilir.