Skip to content

Instantly share code, notes, and snippets.

@cheapwebmonkey
Created May 23, 2015 21:34
Show Gist options
  • Save cheapwebmonkey/5a14769ed6b30fffba8b to your computer and use it in GitHub Desktop.
Save cheapwebmonkey/5a14769ed6b30fffba8b to your computer and use it in GitHub Desktop.
Nested Arrays
<?php
$countries = array();
$countries[0] = array(
"code" => "US",
"name" => "United States",
"capital" => "Washington, D.C.",
"population" => 2250000000,
"anthem" => "The Star-Spangled Banner"
);
$countries[1] = array(
"code" => "DE",
"name" => "Germany",
"capital" => "Berlin",
"population" => 81799600,
"anthem" => "Song of the Germans"
);
?>
<?php foreach($countries as $country) { ?>
<h1><?php echo $country["name"]; ?></h1>
<dl>
<dt>Country Code</dt>
<dd><?php echo $country["code"]; ?></dd>
<dt>Capital</dt>
<dd><?php echo $country["capital"]; ?></dd>
<dt>Population</dt>
<dd><?php echo $country["population"]; ?></dd>
</dl>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment