vendredi 11 décembre 2020

Defining an Array inside a checkbox in php

 <td><input class='checkBoxes' type='checkbox' name="checkBoxArray[]" value="<?php echo $post_id; ?>"></td>

<?php 

if (isset($_POST['checkBoxArray'])) 
{
  foreach($_POST['checkBoxArray'] as $checkBoxValue)
  {
    echo $checkBoxValue;

  }
  
}


?>

name of the checkbox has been named as an array called checkBoxArray[] and the values are getting from the database so dont worry about that.I want to know that does php converts this into an array by itself when we give an array for a name to any field.And why does it automatically grab the values to the array which we have assigned as values in the checkbox.Can i know the whole process please.




Aucun commentaire:

Enregistrer un commentaire