+ 1
How to create a match table
array["Real Madrid","Barcelona","Atletic","Sevilla"] and create, example 1 Real Madrid x Bacelona Atletic x Sevilla 2 Real Madrid x Atletic Sevilla x Barcelona 3 Sevilla x Real Madrid Barcelona x Atletic no repeat games, how make this? https://en.m.wikipedia.org/wiki/Round-robin_tournament
1 Resposta
+ 21
$a = ["Real Madrid","Barcelona","Atletic","Sevilla"];
$length = count($a);
$counter = 1;
for ($i = 0; $i < $length - 1; $i++) {
for ($j = $i + 1; $j < $length; $j++) {
echo $counter++ . ' ';
echo $a[$i] . ' x ' . $a[$j];
echo "<br>";
}
}