<html>
<! Array5.php                                                 >
<! Chapter 6, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This declares an associative array and assigns all         >
<! elements at once then it uses a foreach-loop to mimic the  >
<! print_r() function.                                        >
<head>
<title>
  Chapter 6 : Array5.php
</title>
</head>
<body>
<?php
  // Declare a unique string index array variable.
  $salutation = array("Bilbo"=>"A hobbit who slew a dragon."
                     ,"Frodo"=>"A hobbit that destroyed the one-ring.");

  // Declare string to print an HTML table.
  $output = "<table border=0>";

  // Read and add array keys and values to a string.
  foreach ($salutation as $hashName => $hashValue)
  {
    // Append the element name and value.
    $output .= "<tr>";
    $output .= "<td>[".$hashName."]</td>";
    $output .= "<td>[".$hashValue."]</td>";
    $output .= "</tr>";
  }

  // Close the HTML table.
  $output .= "</table>";

  // Print the formatted stringc.
  print $output;
?>
</body>
</html>
