Checkboxes in an array

I have seen more than once that all checkboxes in the form have the same name name="check[]". It appears to be an array. How to successfully receive it by post and output it in a loop through a regular echo statement? Or maybe there is documentation somewhere about this?


Answer 1, authority 100%

<?php
  if (isset($_POST['check'])){
      $check=$_POST['check'];
      foreach ($check as $ch)
      {
          echo $ch.'<br />';
      }
  }
?>
<form action="" method="post">
  <input type="checkbox" name="check[]" />
  <input type="checkbox" name="check[]" />
  <input type="checkbox" name="check[]" />
<input type="submit" value="Go" />
</form>

That’s how it is. In general, a useful thing is to pass the form values ​​in an array, then it is easier to process and collect the values. You can use multidimensional arrays. name=”check[test1][]”,name=”check[test2][]”.
To see what you take from the post – use the print_r function, it will display everything visually