title: Differentiation Choices in Multiple choice with Multiple Answer Using PHP
body: <p>I have Multiple Choices With Multiple Answer.I Want to different options with correct answer as well as wrong answer.I had already done this type of question with single answer but in this case correct answer may be more than one.
  <a href="https://stackoverflow.com/questions/42580455/differentiate-choices-with-correct-answer-using-php/">Differentiate Choices with Correct Answer using PHP</a>. I had tried like below code but I will get for only single value check not for all.I dont know why</p>
  
  <pre><code>&lt;?php 
  $a1 = [trim($m_o1), trim($m_o2), trim($m_o3), trim($m_o4), trim($m_o5)];
  shuffle($a1);
  $b1      = ['m_o1', 'm_o2', 'm_o3', 'm_o4' ,'m_o5'];
  $result1 = array_combine($b1, $a1);
  extract($result1);
  $sc_flag2=0;
  $actual_flag2=0;
  if($m_c1=='1')
  {
      $correct_answer2 = array(
          $m_oo1
      );
  
  }
  else if($m_c1=='2')
  {
      $correct_answer2 = array(
          $m_oo1,
          $m_oo2
      );
  
  }
  else if($m_c1=='3')
  {
      $correct_answer2 = array(
          $m_oo1,
          $m_oo2,
          $m_oo3
      );
  
  }
  else if($m_c1=='4')
  {
      $correct_answer2 = array(
          $m_oo1,
          $m_oo2,
          $m_oo3,
          $m_oo4
      );
  
  }
  else if($m_c1=='5')
  {
  $correct_answer2 = array(
          $m_oo1,
          $m_oo2,
          $m_oo3,
          $m_oo4,
          $m_oo5
      );
  
  }
  else
  {
      $correct_answer2 = array();
  
  }
  
  $multiple_answer = array(
          $multiple_answer_1_1,
          $multiple_answer_1_2,
          $multiple_answer_1_3,
          $multiple_answer_1_4,
          $multiple_answer_1_5
      );
  //print_r($multiple_answer);
  //print_r($correct_answer2);
  
  if (in_array($m_o1, $correct_answer2) &amp;&amp; in_array($multiple_answer, $correct_answer2)) {
      $sc_flag2 = 1; // student's selected correct flag
  }
  if (in_array($m_o2, $correct_answer2) &amp;&amp; in_array($multiple_answer, $correct_answer2)) {
      $sc_flag2 = 2; // student's selected correct flag
  }
  if (in_array($m_o3, $correct_answer2) &amp;&amp; in_array($multiple_answer, $correct_answer2)) {
      $sc_flag2 = 3; // student's selected correct flag
  }
  if (in_array($m_o4, $correct_answer2) &amp;&amp; in_array($multiple_answer, $correct_answer2)) {
      $sc_flag2 = 4; // student's selected correct flag
  }
  if (in_array($m_o5, $correct_answer2) &amp;&amp; in_array($multiple_answer, $correct_answer2)) {
      $sc_flag2 = 5; // student's selected correct flag
  }
  
  if (in_array($m_o1, $correct_answer2)) {
      $correct_flag2 = 1; // student's selected correct flag
  }
  if (in_array($m_o2, $correct_answer2)) {
      $correct_flag2 = 2; // student's selected correct flag
  }
  if (in_array($m_o3, $correct_answer2)) {
      $correct_flag = 3; // student's selected correct flag
  }
  if (in_array($m_o4, $correct_answer2)) {
      $correct_flag2 = 4; // student's selected correct flag
  }
  if (in_array($m_o5, $correct_answer2)) {
      $correct_flag2 = 5; // student's selected correct flag
  }
  if (in_array($m_o1, $multiple_answer)) {
      $actual_flag2 = 1; // student's selected correct flag
  }
  if (in_array($m_o2, $multiple_answer)) {
      $actual_flag2 = 2; // student's selected correct flag
  }
  if (in_array($m_o3, $multiple_answer)) {
      $actual_flag2 = 3; // student's selected correct flag
  }
  if (in_array($m_o4, $multiple_answer)) {
      $actual_flag2 = 4; // student's selected correct flag
  }
  if (in_array($m_o5, $multiple_answer)) {
      $actual_flag2 = 5; // student's selected correct flag
  }
  ?&gt;
  &lt;?php if ($sc_flag2 == 1) { // correct answer by student green// see for correct option I had added green border and bg but tht time alps yello bg oisk showingokok ?&gt;
      &lt;label style="font-size:14px;background-color:#90EE90;border:1px solid green;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(A) &lt;?php echo $m_o1; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($actual_flag2 == 1 &amp;&amp; $correct_flag2 != 1) { // student's answer is wrong here and student answer is given red
      ?&gt;
      &lt;label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-times" style="color:red;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(A) &lt;?php echo $m_o1; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($correct_flag2 == 1) { // student have not given answer and correct option will be yellow ?&gt;
      &lt;label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(A) &lt;?php echo $m_o1; ?&gt;
      &lt;/label&gt;
  &lt;?php } else {?&gt;
      &lt;label style="font-size:14px"&gt;
          &lt;span class=""&gt;&lt;input type="checkbox" value="&lt;?php echo $m_o1; ?&gt;" &gt;&lt;/span&gt; (A) &lt;?php echo $m_o1; ?&gt;
      &lt;/label&gt;
  &lt;?php }?&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;?php if ($sc_flag2 == 2) {?&gt;
      &lt;label style="font-size:14px;background-color:#90EE90;border:1px solid green;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(B) &lt;?php echo $m_o2; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($actual_flag2 == 2 &amp;&amp; $correct_flag2 != 2) {
      ?&gt;
      &lt;label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-times" style="color:red;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(B) &lt;?php echo $m_o2; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($correct_flag2 == 2) {?&gt;
      &lt;label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(B) &lt;?php echo $m_o2; ?&gt;
      &lt;/label&gt;
  &lt;?php } else {?&gt;
      &lt;label style="font-size:14px"&gt;
          &lt;span class=""&gt;&lt;input type="checkbox" value="&lt;?php echo $m_o2; ?&gt;" &gt;&lt;/span&gt; (B) &lt;?php echo $m_o2; ?&gt;
      &lt;/label&gt;
  &lt;?php }?&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;?php if ($sc_flag2 == 3) {?&gt;
      &lt;label style="font-size:14px;background-color:#90EE90;border:1px solid green;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(C) &lt;?php echo $m_o3; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($actual_flag2 == 3 &amp;&amp; $correct_flag2 != 3) {
      ?&gt;
      &lt;label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-times" style="color:red;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(C) &lt;?php echo $m_o3; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($correct_flag2 == 3) {?&gt;
      &lt;label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(C) &lt;?php echo $m_o3; ?&gt;
      &lt;/label&gt;
  &lt;?php } else {?&gt;
      &lt;label style="font-size:14px"&gt;
          &lt;span class=""&gt;&lt;input type="checkbox" value="&lt;?php echo $m_o3; ?&gt;" &gt;&lt;/span&gt; (C) &lt;?php echo $m_o3; ?&gt;
      &lt;/label&gt;
  &lt;?php }?&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;?php if ($sc_flag2 == 4) {?&gt;
      &lt;label style="font-size:14px;background-color:#90EE90;border:1px solid green;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(D) &lt;?php echo $m_o4; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($actual_flag2 == 4 &amp;&amp; $correct_flag2 != 4) {
      ?&gt;
      &lt;label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-times" style="color:red;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(D) &lt;?php echo $m_o4; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($correct_flag2 == 4) {?&gt;
      &lt;label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(D) &lt;?php echo $m_o4; ?&gt;
      &lt;/label&gt;
  &lt;?php } else {?&gt;
      &lt;label style="font-size:14px"&gt;
          &lt;span class=""&gt;&lt;input type="checkbox" value="&lt;?php echo $m_o4; ?&gt;" &gt;&lt;/span&gt; (D) &lt;?php echo $m_o4; ?&gt;
      &lt;/label&gt;
  &lt;?php }?&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;?php if ($sc_flag2 == 5) {?&gt;
      &lt;label style="font-size:14px;background-color:#90EE90;border:1px solid green;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(E) &lt;?php echo $m_o5; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($actual_flag2 == 5 &amp;&amp; $correct_flag2 != 5) {
      ?&gt;
      &lt;label style="font-size:14px;background-color:lightgray;border:1px solid red;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-times" style="color:red;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(E) &lt;?php echo $m_o5; ?&gt;
      &lt;/label&gt;
  &lt;?php } else if ($correct_flag2 == 5) {?&gt;
      &lt;label style="font-size:14px;background-color:yellow;border:1px solid yellow;padding:10px" &gt;
          &lt;label class="review-icon"&gt;&lt;i class="fa fa-fw fa-check-circle-o" style="color:green;font-size:15px"&gt;&lt;/i&gt;&lt;/label&gt;
          &lt;span class=""&gt;(E) &lt;?php echo $m_o5; ?&gt;
      &lt;/label&gt;
  &lt;?php } else {?&gt;
      &lt;label style="font-size:14px"&gt;
          &lt;span class=""&gt;&lt;input type="checkbox" value="&lt;?php echo $m_o5; ?&gt;" &gt;&lt;/span&gt; (D) &lt;?php echo $m_o5; ?&gt;
      &lt;/label&gt;
  &lt;?php }?&gt;&lt;br/&gt;&lt;br/&gt;
  </code></pre>
  
  <p>My array values are </p>
  
  <pre><code> for $a1=which means list of options like
  
          Array ( [0] =&gt; Larger animals in the same territory may vacate their burrows for meerkats to stay in them. [1] =&gt; The organised lifestyle and the peculiar body structures help meerkats live a comfortable life in extremities. [2] =&gt; Territorial fights are usually organised to solve disputes about all problems. [3] =&gt; Meerkats show strong solidarity with their group members for the sake of their safety and comfort. [4] =&gt; Meerkats dig their burrows in a unique way, having around 15 entrance and exit holes. )
  </code></pre>
  
  <p>Answers given by student where we need to compare this options</p>
  
  <p>$multiple_answers=    Array ( [0] => Larger animals in the same territory may vacate their burrows for meerkats to stay in them. [1] => Meerkats dig their burrows in a unique way, having around 15 entrance and exit holes. [2] => undefined [3] => undefined [4] => undefined )</p>
  
  <p>And my correct <code>answer2=Array ( [0] =&gt; Meerkats show strong solidarity with their group members for the sake of their safety and comfort. [1] =&gt; The organised lifestyle and the peculiar body structures help meerkats live a comfortable life in extremities. )</code></p>
  
  <p>Here I want the result with </p>
  
  <p>[0] => Larger animals in the same territory may vacate their burrows for meerkats to stay in them. [1] => Meerkats dig their burrows in a unique way, having around 15 entrance and exit holes.This two option value with red. And the options with  [0] => Meerkats show strong solidarity with their group members for the sake of their safety and comfort. [1] => The organised lifestyle and the peculiar body structures help meerkats live a comfortable life in extremities.With yellow.But Im getting output with wrong Answer.Please check my code and let me know what are the mistakes ?Plese anyone help me to get out of this issue.Thanks in advance.Thank u somuch.</p>