title: How to retrieve multiple check box value using explode?
body: <p>I have several check boxes and when the multiple check box is clicked &amp; form is submitted it goes in the db search for the corresponding result but it is giving me notice :</p>
  
  <pre><code>Warning: explode() expects parameter 2 to be string, array given in C:\xampp\htdocs\enoticeboard\home.php on line 68
  </code></pre>
  
  <p>this error is 3 times.</p>
  
  <p>how I successfully retrieve it?
  my code is:</p>
  
  <pre><code>&lt;?php
  include_once 'dbconfig.php';
  if(!$user-&gt;is_loggedin())
  {
     $user-&gt;redirect('index.php');
  }
  $user_id = $_SESSION['user_session'];
  $stmt = $DB_con-&gt;prepare("SELECT * FROM users WHERE user_id=:user_id");
  $stmt-&gt;execute(array(":user_id"=&gt;$user_id));
  $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
  ?&gt;
  
  
  
   &lt;!DOCTYPE&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" /&gt;
      &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
      &lt;title&gt;welcome -
          &lt;?php print($userRow[ 'user_email']); ?&gt;
      &lt;/title&gt;
      &lt;style&gt;
          .left {
              margin-left: 20px;
              width: 100px;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;div class="header"&gt;
          &lt;div class="left"&gt;
              &lt;label&gt;&lt;a&gt;Welcome : &lt;?php print($userRow['user_name']); ?&gt;&lt;/a&gt; &lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="right"&gt;
              &lt;label&gt;&lt;a href="logout.php?logout=true"&gt;&lt;i class="glyphicon glyphicon-log-out"&gt;&lt;/i&gt; logout&lt;/a&gt;
              &lt;/label&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="content"&gt;
          &lt;h1&gt;Notice Board&lt;/h1&gt;
          &lt;div class="left"&gt;
              &lt;h4&gt;Select Hostel,Branch,Year&lt;/h4&gt;
              &lt;form action="home.php" method="POST"&gt;
                  &lt;label&gt;Hostel&lt;/label&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="hostel[]" value="K.P-1"&gt;K.P-1&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="hostel[]" value="K.P-2"&gt;K.P-2&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="hostel[]" value="K.P-3"&gt;K.P-3&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;label&gt;Branch&lt;/label&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="branch[]" value="CSE"&gt;CSE&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="branch[]" value="I.T"&gt;I.T&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="branch[]" value="CIVIL"&gt;CIVIL&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;label&gt;YEAR&lt;/label&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="year[]" value="2011"&gt;2011&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="year[]" value="2012"&gt;2012&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="checkbox" name="year[]" value="2013"&gt;2013&lt;/input&gt;
                  &lt;br/&gt;
                  &lt;input type="submit" value="See Notices" /&gt;
              &lt;/form&gt;
          &lt;/div&gt;
   &lt;?php
   if(isset($_POST['hostel']) &amp;&amp; isset($_POST['branch']) &amp;&amp; isset($_POST['year']))
  {
      if(!empty($_POST['hostel']) &amp;&amp; !empty($_POST['branch']) &amp;&amp;  !empty($_POST['year']))
  {
              $arrayName = $_POST['hostel'];
              $arrayName2 = $_POST['branch'];
              $arrayName3 = $_POST['year'];
              $hostel=explode(",",$arrayName);
              $branch=explode(",",$arrayName2);
              $year=explode(",",$arrayName3);
              $stmt2=$DB_con-&gt;prepare("SELECT * FROM doc WHERE hostel=:hostel AND branch=:branch AND year=:year");
              $stmt2-&gt;execute(array(':hostel'=&gt;$hostel,':branch'=&gt;$branch,':year'=&gt;$year));
              $userRow2=$stmt2-&gt;fetch(PDO::FETCH_ASSOC);
               ?&gt;
              &lt;div class="middle"&gt;
                  &lt;?php
                  if($userRow2 &gt; 0){
                          foreach($userRow2['doc'] as $value2){
                          print_r($value2['doc']);
                          echo 'hi';
                  }
              }
              else {
                  echo "No records.";
              }
                  ?&gt;
                  &lt;/div&gt;
                  &lt;?php
  
          }
          else {
              echo "No Notice Found.";
          }
  }
  else {
      echo "Please fill in all fields.";
   }
   ?&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>