Created
May 23, 2015 21:34
-
-
Save cheapwebmonkey/5a14769ed6b30fffba8b to your computer and use it in GitHub Desktop.
Nested Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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