title: PHP quiz - display correct and incorrect answers
body: <p>I have a php quiz script that I have been using and am trying to modify it to display both correct and incorrect answers and am having issues trying to accomplish this.</p>
  
  <p>So when a user selects the incorrect answer, I want the script to display the incorrect answer and then the correct answer below it. I have figure out how to display the letter of the correct answer, but I want the actual answer to be displayed and not just the letter.</p>
  
  <p>I am a beginner with php so any help would be appreciated.</p>
  
  <p>Here is the entire code:</p>
  
  <pre><code>&lt;?php get_header();
  
  /*
  Template Name: PHP Quiz safety asmnt
  */
  
  
  $Questions = array(
      1 =&gt; array(
          'Question' =&gt; 'The appropriate response during a health threatening emergency such as a fire or toxic spill is to:',
          'Answers' =&gt; array(
              'A' =&gt; 'Pull the fire alarm; evacuate immediately to the assemply point; and do not re-enter the cleanroom until instructed to do so.',
              'B' =&gt; 'Notify lab; evacuate immediately to the assemply point; and do not re-enter the cleanroom until instructed to do so.',
              'C' =&gt; 'Call EH&amp;S'
          ),
          'CorrectAnswer' =&gt; 'A'
      ),
      2 =&gt; array(
          'Question' =&gt; 'With proper use of wet bench and disposal procedures, the laboratory should be free of odors. In general, if you smell something, you should:',
          'Answers' =&gt; array(
              'A' =&gt; 'Call EH&amp;S; Clear affected area if necessary; Notify staff and other users',
              'B' =&gt; 'Do nothing; odd smells are normal when working in the cleanroom.',
              'C' =&gt; 'Notify staff member; clear affected area; wait for instruction from staff who will investigate'
          ),
          'CorrectAnswer' =&gt; 'C'
      )
  );  
  
  ?&gt;
   &lt;div id="bodyPage" class="clear"&gt;
  &lt;!------- start body -------&gt;
  &lt;section id="contentPage"&gt;
  
  &lt;h1 class="title"&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
  
  &lt;?php 
  
  if (isset($_POST['answers'])){
      $Answers = $_POST['answers']; // Get submitted answers.
      echo '&lt;br /&gt;';
  
      // Automated question checking!)
  
      foreach ($Questions as $QuestionNo =&gt; $Value){
          // Echo the question
           echo $QuestionNo. '.&amp;nbsp;&amp;nbsp;' .$Value['Question'].'&lt;blockquote&gt;';
  
          if ($Answers[$QuestionNo] != $Value['CorrectAnswer']){
              echo 'You entered incorrectly:&lt;br /&gt;'.'&lt;span style="color: red;"&gt;'.$Value['Answers'][$Answers[$QuestionNo]].'&lt;/span&gt;';
              echo '&lt;br/&gt;'.'The correct answer is:&lt;br /&gt;'.'&lt;span style="color: green;"&gt;'.$Value['CorrectAnswer'][$Answers[$QuestionNo]].'&lt;/span&gt;';
          } else {
          echo 'You entered correctly:&lt;br /&gt;'.'&lt;span style="color: green;"&gt;'.$Value['Answers'][$Answers[$QuestionNo]].'&lt;/span&gt;';
          }
          echo '&lt;/blockquote&gt;';
  
      }
  
      } else {
  
  
   ?&gt;
  
      &lt;form action="&lt;?php the_permalink(); ?&gt;" method="post" id="quiz"&gt;
  
      &lt;ol&gt;
      &lt;?php foreach ($Questions as $QuestionNo =&gt; $Value){ ?&gt;
  
      &lt;li&gt;
          &lt;h4&gt;&lt;?php echo $Value['Question']; ?&gt;&lt;/h4&gt;
          &lt;?php 
              foreach ($Value['Answers'] as $Letter =&gt; $Answer){ 
              $Label = 'question-'.$QuestionNo.'-answers-'.$Letter;
          ?&gt;
          &lt;div&gt;
              &lt;input type="radio" name="answers[&lt;?php echo $QuestionNo; ?&gt;]" id="&lt;?php echo $Label; ?&gt;" value="&lt;?php echo $Letter; ?&gt;" /&gt;
              &lt;label for="&lt;?php echo $Label; ?&gt;"&gt;&lt;!--&lt;?php echo $Letter; ?&gt;)--&gt; &lt;?php echo $Answer; ?&gt; &lt;/label&gt;
          &lt;/div&gt;
          &lt;?php } ?&gt;
      &lt;/li&gt;
  
      &lt;?php } ?&gt;
      &lt;/ol&gt;
      &lt;input type="submit" value="Submit Quiz" /&gt;
      &lt;/form&gt;
  &lt;?php 
  }
  ?&gt;
  
  &lt;!------- end body -------&gt;
  &lt;/div&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>