title: for loop setting a var based on checkbox
body: <p>I have a system that allows a user to create a question where each possible answer has a checkbox. If that is checked then that answer is the correct one. I save the <code>answer_id</code> in the database, and a TRUE or FALSE value as to whether it is correct or not. However, I am struggling to set the incorrect answers to FALSE since an unset checkbox does not seem to go into the POST.</p>
  
  <pre><code>$count = count($_POST['answer']);
  $answers = array();
  for($i = 0; $i &lt; $count; $i ++) {
      if(isset($_POST['correct'][$i])) {
          $correct = "true";
      } else {
          $correct = "false";
      }
      $answers[] = array(
          'answer' =&gt; $_POST['answer'][$i],
          'correct' =&gt; $correct
      );
  }
  </code></pre>
  
  <p>Am I doing something wrong?</p>