loopingArrays.php
Source of loopingArrays.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>loopingArrays.php</title>
</head>
<body>
<h1>Looping through arrays</h1>
<div>
<?php
//first make an array of mini-book names
$books = array("Creating the HTML Foundation",
"Styling with CSS",
"Using Positional CSS for Layout",
"Client-Side Programming with JavaScript",
"Server-Side Programming with PHP",
"Databases with MySQL",
"Into the Future with AJAX",
"Moving From Pages to Web Sites");
//just print them out with a loop
print "<p> \n";
for ($i = 0; $i < sizeof($books);$i++){
print $books[$i] . "<br />\n";
} // end for
print "</p> \n";
//use the foreach mechanism to simplify printing out the elements
print "<p> \n";
foreach ($books as $book){
print $book . " <br />\n";
} // end foreach
print "</p> \n";
?>
</div>
</body>
</html>