Skip to content

Instantly share code, notes, and snippets.

@yoander
Last active July 23, 2018 02:11
Show Gist options
  • Save yoander/3ae5c6b039782a8d949d6d9893c84da0 to your computer and use it in GitHub Desktop.
Save yoander/3ae5c6b039782a8d949d6d9893c84da0 to your computer and use it in GitHub Desktop.
<?php
$countries = [
['country' => 'Spain', 'lang' => 'ES', 'currency' => 'EUR'],
['country' => 'USA', 'lang' => 'EN', 'currency' => 'USD']
];
foreach ($countries as ['country' => $countryName, 'lang' => $language, 'currency' => $currency]) {
echo "<strong>Country: </strong> $countryName, <strong>Language: </strong> $language, <strong>Currency: </strong> $currency";
echo nl2br("\n");
}
// Print
// Country: Spain, Language: ES, Currency: EUR
// Country: USA, Language: EN, Currency: USD
<?php
echo "<strong>Countries:</strong>", nl2br("\n");
$countries = [
'SPAIN' => ['EUR', 'ES'],
'USA' => ['USD', 'EN'],
'ECUADOR' => ['USD', 'ES'],
'CUBA' => ['CUC', 'ES'],
'FRANCE' => ['EUR', 'FR']
];
foreach ($countries as $countryName => [$currency, $lang]) {
echo "<strong>Country: </strong> $countryName, <strong>Currency: </strong> $currency, <strong>Language: </strong> $lang";
echo nl2br("\n");
}
<?php
$playerRank = [
['Carlsen', 'Norway', 2842],
['Caruana', 'USA', 2822],
['Mamedyarov', 'Azerbaijan', 2801],
['Ding Liren', 'China', 2797],
['Kramnik', 'Russia', 2790],
];
[$player1, $player2] = $playerRank;
echo "<strong>Player 1 is:</strong>", nl2br("\n");
foreach ($player1 as $data) {
echo $data, nl2br("\n");
}
echo nl2br("\n");
echo "<strong>Player 2 is:</strong>", nl2br("\n");
foreach ($player2 as $data) {
echo $data, nl2br("\n");
}
echo nl2br("\n");
echo "<strong>Player List:</strong>", nl2br("\n");
foreach ($playerRank as [$name, $country, $elo]) {
echo "<strong>Player Name:</strong> $name, ", "<strong>Player Country: </strong> $country,", "<strong>Elo: </strong> $elo";
echo nl2br("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment