title: How do I create a content page that contain boxes which link to different arrays in PHP?
body: <p>I'm wondering how to create a menu template which allows you to go into different pages in PHP? I'm an amateur to PHP and is still new to a lot of new things. I want to create something like this : <a href="http://i.stack.imgur.com/ylfe8.jpg" rel="nofollow">http://i.stack.imgur.com/ylfe8.jpg</a></p>
  
  <p>This is the code that I came up with for the nav bar but how to create the menu page? Thanks so much in advance.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;title&gt;Smart Quizzes &lt;/title&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
          &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
          &lt;link href="css/css.css" rel="stylesheet"&gt;
                  &lt;script src= "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src= "js/bootstrap.js"&gt; &lt;/script&gt;   
          &lt;/head&gt;
  
      &lt;body&gt;
  
  
          &lt;div class = "navbar navbar-inverse navbar-static-top"&gt;
              &lt;div class = "container"&gt;
                  &lt;div class="navbar-header"&gt;
                     &lt;a href= "nav.php" class = "navbar-brand"&gt;&lt;img src="img/logo.jpg" width="50" height="40" border="0"&gt; Smart Quizzes &lt;/a&gt; 
  
  
  
                      &lt;button class = "navbar-toggle" data-toggle= "collapse" data-target = ".navHeaderCollapse"&gt;
                          &lt;span class = "icon-bar"&gt; &lt;/span&gt;
                          &lt;span class = "icon-bar"&gt; &lt;/span&gt;
                          &lt;span class = "icon-bar"&gt; &lt;/span&gt;
  
                      &lt;/button&gt;
  
                  &lt;/div&gt;
                  &lt;div class = "collapse navbar-collapse navHeaderCollapse"&gt;
  
                      &lt;ul class = "nav navbar-nav navbar-right"&gt;
  
                                              &lt;li class = "active"&gt;&lt;a href = "nav.php" About &lt;/a&gt;&lt;/li&gt;
  
                          &lt;li class = "dropdown"&gt;
  
                              &lt;a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"&gt;Quizzes &lt;b class = "caret"&gt; &lt;/b&gt;&lt;/a&gt;
                              &lt;ul class = "dropdown-menu"&gt;
                                  &lt;li&gt;&lt;a href = "#"&gt;Singapore History&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href = "#"&gt;Basic Php&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href = "#"&gt;HTML/CSS/JavaScript+&lt;/a&gt;&lt;/li&gt;
                                  &lt;li&gt;&lt;a href = "#"&gt;Basic Math&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;
                              &lt;li&gt;&lt;a href = "#"&gt; Contact Us&lt;/a&gt;&lt;/li&gt;                                                
  
  
                      &lt;/ul&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>My code look something like this, which is in a separate php file as my menu.php</strong></p>
  
  <pre><code>`&lt;html&gt;
  
  &lt;body&gt;
      &lt;?php
  
          $quizHistoryQ = [
  
              "Q1" =&gt; ["questions"=&gt;"ABC?",
                  "options" =&gt; ["this is option 1",
                                 "this is option 2",
                                  "this is option 3"],
                  "answer" =&gt;2
          ],
  
             "Q2" =&gt; ["questions"=&gt;"This is the Question String for question 2",
                  "options" =&gt; ["this is option A",
                                 "this is option B",
                                  "this is option C"],
                  "answer" =&gt;1
          ],
  
                 "Q3" =&gt;["questions"=&gt;"This is the Question String for question 3",
                  "options" =&gt; ["this is option X",
                                 "this is option Y",
                                  "this is option Z"],
                  "answer" =&gt;0
          ]
              ];
  
  
  
  
  
          $quizMathQ = [ 
  
              "q1" =&gt; ["questions"=&gt;"This is the Question String for question 1",
  
                  "options" =&gt; ["this is option 1",
                                 "this is option 2",
                                  "this is option 3"],
                  "answer" =&gt;2
          ],
  
             "q2" =&gt; ["questions"=&gt;"This is the Question String for question 2",
                  "options" =&gt; ["this is option A",
                                 "this is option B",
                                  "this is option C"],
                  "answer" =&gt;1
          ],
  
                 "q3" =&gt;["questions"=&gt;"This is the Question String for question 3",
                  "options" =&gt; ["this is option X",
                                 "this is option Y",
                                  "this is option Z"],
                  "answer" =&gt;0
          ]
              ];
  
  
  
          $quizHTMLQ = [ "q1" =&gt; ["questions"=&gt;"This is the Question String for question 1",
                  "options" =&gt; ["this is option 1",
                                 "this is option 2",
                                  "this is option 3"],
                  "answer" =&gt;2
          ],
  
             "q2" =&gt; ["questions"=&gt;"This is the Question String for question 2",
                  "options" =&gt; ["this is option A",
                                 "this is option B",
                                  "this is option C"],
                  "answer" =&gt;1
          ],
  
                 "q3" =&gt;["questions"=&gt;"This is the Question String for question 3",
                  "options" =&gt; ["this is option X",
                                 "this is option Y",
                                  "this is option Z"],
                  "answer" =&gt;0
          ]
              ];
  
  
          $allQuizArr = [$quizHistoryQ, $quizMathQ, $quizHTMLQ];
  
  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>With a PHP file like that, can I use a code like the following to create the menu page, how do I use it? (The code doesn't work)</strong></p>
  
  <pre><code>   &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
  
          &lt;?php
          require_once 'getData.php';
  
  function quizTitles($quizzes_title) {
      $output = "";
      $output = $output . '&lt;li class =" ' . $quizzes_title["$quizHistoryQ"] . ' "&gt; '; 
      $output = $output . '&lt;a href=" ' . $quizzes_title["$quizMathQ"] . ' "&gt;';
      $output = $output . '&lt;img src=" ' . $quizzes_title["$quizHTMLQ"] . ' "&gt; ';
      $output = $output . '&lt;/a&gt;';
      $output = $output . '&lt;/li&gt;';
  
     return $output;
  
  }
  
  foreach($quizTitles as $quizzes_titles) {
    echo quizTitles($quizzes_titles);
   } 
  
  ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>