Tarihleri ​​sözdizimi konu ile döngü

2 Cevap

Ben futbol / futbol oyunları için bir fikstür jeneratör oluşturduk ...

    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]";
        }
    }

Neredeyse orada olduğum gibi ben soruyu değiştirerek ediyorum.

$roundDates[$round]

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

2 Cevap

you want the first date 4 days from now

çevirir + 4 (değil * 4)

Bu aynı zamanda daha net neden $i sıfır tabanlı olmalıdır yapmak gerekir:

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

maketime(), 5'inci argüman olarak gün sayısını alır ile tarihini oluşturun.

$date = time() + maketime(NULL, NULL, NULL, NULL, $i);