Please send questions to
st10@humboldt.edu .
<html>
<!-- adapted from an example in the PHP manual -->
<head>
<title> array1.php </title>
</head>
<body>
<h1>
<?php
$shopping = array("fruit" => "apple", 13 => 9,
"cereal" => "Grape Nuts");
print $shopping["fruit"] . "<br>\n";
print $shopping[13] . "<br>\n";
print $shopping["cereal"] . "<br>\n";
$arr2 = array("fruit" => "cherry", 13 => 2, 27, "harry");
?>
<ul>
<?php
foreach ($arr2 as $latestKey => $latestValue)
{
print "<li> " . $latestKey . ": " . $latestValue . "\n";
}
?>
</ul>
<?php
$arr3 = array("fruit" => "plum", "a", "b", "c");
print "<ul>\n";
foreach ($arr3 as $latestKey => $latestValue)
{
print "<li> " . $latestKey . ": " . $latestValue . "\n";
}
?>
</ul>
<?php
$arr3["fruit"] = "bananas";
$arr3["meat"] = "Spam";
print "<ul>\n";
foreach ($arr3 as $latestKey => $latestValue)
{
print "<li> " . $latestKey . ": " . $latestValue . "\n";
}
?>
</ul>
</h1>
</body>
</html>