Skip to content

Instantly share code, notes, and snippets.

@waxim
Created June 11, 2021 16:54
Show Gist options
  • Save waxim/c5de4842c030f5fc4336ccfddf666c4a to your computer and use it in GitHub Desktop.
Save waxim/c5de4842c030f5fc4336ccfddf666c4a to your computer and use it in GitHub Desktop.
<?php
$teams = [
'Austria',
'Belgium',
'Croatia',
'Czech Republic',
'Denmark',
'England',
'Finland',
'France',
'Germany',
'Hungary',
'Italy',
'North Macedonia',
'Netherlands',
'Poland',
'Portugal',
'Russia',
'Scotland',
'Slovakia',
'Spain',
'Sweden',
'Switzerland',
'Turkey',
'Ukraine',
'Wales',
];
$players = [
'Alan',
'Dom',
'Leo',
'Rob',
'Ross',
'Gaj',
'Dan',
'David',
'Rhia',
'Joe',
'Clem',
'Claudia',
'Claudia K',
'John',
'Kyle',
'Pete',
'Corentin',
'Arthur',
'Fletch',
'Johno',
'Matt',
'Chatity #1',
'Charity #2',
];
$picks = [];
foreach($players as $player) {
$pick = array_rand($teams);
$picks[$teams[$pick]] = $player;
echo "Player $player has picked team " . $teams[$pick] . " from the hat." . PHP_EOL;
unset($teams[$pick]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment