Skip to content

Instantly share code, notes, and snippets.

@DaMitchell
Created May 31, 2018 17:19
Show Gist options
  • Save DaMitchell/7e55a3bab9e0a1cf467800fe098f602d to your computer and use it in GitHub Desktop.
Save DaMitchell/7e55a3bab9e0a1cf467800fe098f602d to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
$bands = [[
"germany",
"brazil",
"portugal",
"argentina",
"belgium",
"poland",
],[
"france",
"spain",
"peru",
"switzerland",
"england",
"colombia",
],[
"mexico",
"uruguay",
"croatia",
"denmark",
"iceland",
"costa rica",
],[
"sweden",
"tunisia",
"egypt",
"senegal",
"iran",
"serbia",
],[
"nigeria",
"australia",
"japan",
"morocco",
"panama",
"russia",
]];
$players = [
['name' => 'Chris', 'countries' => []],
['name' => 'Dan', 'countries' => []],
['name' => 'Darren', 'countries' => []],
['name' => 'Jamie', 'countries' => []],
['name' => 'Rob', 'countries' => []],
];
shuffle($players);
shuffle($players);
shuffle($players);
$player = 0;
foreach ($bands as $band) {
shuffle($band);
shuffle($band);
shuffle($band);
while (!empty($band)) {
$i = rand(0, count($band) - 1);
$players[$player]['countries'][] = $band[$i];
unset($band[$i]);
$band = array_values($band);
$player++;
if ($player === count($players)) {
$player = 0;
}
}
}
foreach ($players as $player) {
echo "------------------\n";
echo $player['name'] . "\n";
foreach($player['countries'] as $country) {
echo " - " . ucfirst($country) . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment