grazie mille.

Per chi fosse interessato, questo è il cuore dell'algoritmo

codice:
// $teams è il numero di squadre

$totalRounds = $teams - 1;
$matchesPerRound = $teams / 2;

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] = team_name($home + 1, $names) 
                . " v " . team_name($away + 1, $names);
        }
    }
Non è che abbia capito molto bene la regola matematica di questo ciclo, però funziona