<?php
$countries = [
'Africa' => [ "Mammuthus columbi",
"African buffalo",
"Bongo",
"Giraffe",
"Zebra"],
'Australia' => [ "Australian echidna",
"Asian buffalo",
"Camel",
"Dingo",
"Kangaroo"],
];
foreach ($countries as $country => $cities) {
echo '<h2>' . $country, '</h2><br>';
foreach ($cities as $key => $city) {
echo $city . ',' . '<br>';
}
}
?>
$countries = [
'Africa' => [ "Mammuthus columbi",
"African buffalo",
"Bongo",
"Giraffe",
"Zebra"],
'Australia' => [ "Australian echidna",
"Asian buffalo",
"Camel",
"Dingo",
"Kangaroo"],
];
foreach ($countries as $country => $cities) {
echo '<h2>'.$country.'</h2><br/>'.implode(',<br/>', $cities).'.<br/>';
}
<?php
$countries = [
'Africa' => [
"Mammuthus columbi",
"African buffalo",
"Bongo",
"Giraffe",
"Zebra",
],
'Australia' => [
"Australian echidna",
"Asian buffalo",
"Camel",
"Dingo",
"Kangaroo",
],
];
foreach ($countries as $country => $cities) {
echo '<h2>' . $country, '</h2><br>';
echo implode(',<br>', $cities) . '.';
}