1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4. <head>
5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6. <title>My Books and Chapters</title>
7. </head>
8. <body>
9. <?php // Script 7.4 - books.php
10. /* This script creates and prints out a multidimensional array. */
11. // Address error management, if you want.
12.
13. // Create the first array:
14. $phpvqs = array (1 => 'Getting Started', 'Variables', 'HTML Forms and PHP', 'Using Numbers');
15.
16. // Create the second array:
17. $phpadv = array (1 => 'Advanced PHP Techniques', 'Developing Web Applications', 'Advanced Database Concepts', 'Security Techniques');
18.
19. // Create the third array:
20. $phpmysql = array (1 => 'Introduction to PHP', 'Programming with PHP', 'Creating Dynamic Web Sites', 'Introduction to MySQL');
21.
22. // Create the multidimensional array:
23. $books = array (
24. 'PHP VQS' => $phpvqs,
25. 'PHP 5 Advanced VQP' => $phpadv,
26. 'PHP 6 and MySQL 5 VQP' => $phpmysql
27. );
28.
29. // Print out some values:
30. print "<p>The third chapter of my first book is <i>{$books['PHP VQS'][3]}</i>.</p>";
31. print "<p>The first chapter of my second book is <i>{$books['PHP 5 Advanced VQP'][1]}</i>.</p>";
32. print "<p>The fourth chapter of my fourth book is <i>{$books['PHP 6 and MySQL 5 VQP'][4]}</i>.</p>";
33.
34. // See what happens with foreach:
35. foreach ($books as $key => $value) {
36. print "<p>$key: $value</p>\n";
37. }
38.
39. ?>
40. </body>
41. </html>