Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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