Using foreach
Using foreach
- title
- The Grapes of Wrath
- author
- John Steinbeck
- pubYear
- 1939
CODE FOLLOWS
<?php
// Include the header file (assumed to contain common HTML and styles)
include('includes/header.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Using foreach</title>
<link rel="stylesheet" type="text/css" href="css/common.css" />
</head>
<body>
<h1>Using foreach</h1>
<dl>
<?php
$myBook = array( "title" => "The Grapes of Wrath",
"author" => "John Steinbeck",
"pubYear" => 1939 );
foreach ( $myBook as $key => $value ) {
echo "<dt>$key</dt>";
echo "<dd>$value</dd>";
}
?>
</dl>
</body>
</html>
<?php
// Include the footer file (assumed to contain closing HTML and scripts)
include('includes/footer.php');
?>