title: Check if array of checkboxes are checked from a form (PHP)
body: <p>I realize this is a question that has been asked before ("Cannot use [] for reading"), but I'm having trouble wrapping my head around the answer and how to fix my particular function.</p>
  
  <pre><code>function check_required_checkbox($checkbox_name, $error, $is_multiple_checkboxes)
  {
      global $error_msgs;
      if ($is_multiple_checkboxes == true)
      {
          if (!isset($_POST[$checkbox_name][]))
          {
              $error_msgs[] = $error;
          }
      else if ($is_multiple_checkboxes == false)
      {
          if (!isset($_POST[$checkbox_name]))
          {
              $error_msgs[] = $error;
          }
      }
  }
  </code></pre>
  
  <p>The problem line is 6, <code>!isset($_POST[$checkbox_name][])</code>, and I'm not understanding how the correct way I should write it.  I saw instances of using brackets but <code>!isset($_POST[{$checkbox_name}][])</code> isn't correct either.</p>
  
  <p>When I have multiple checkboxes that use <code>name="radda[]"</code>, I want my function to check that all of the checkboxes with a specific name are checked, and if not, add <code>$error</code> to the <code>$error_msgs[]</code> array.</p>
  
  <p><strong>EDIT:</strong>
  I discussed with the department that was requesting a rewrite of the old form.  Instead of using checkboxes, I switched it to a list of all of the borrower's rights and responsibilities, and then used a radio button below the list to ask the user to select "yes" or "no" on whether they read the list.  Then I made it required to select "yes" or "no" and added validation that if "no" was selected, they wouldn't be able to submit the application.  This was <em>far</em> easier than trying to make a bunch of checkboxes required.  I do appreciate the help that everyone offered though.</p>