title: How to get values from textbox in checkbox in php
body: <p>I have 4 checkboxes, one of them is <code>Others</code> have textbox, i want to get all the values that the user checked and if he checked others option to get the values from the textbox associated with <code>Others</code> checkbox.</p>
  
  <p><strong>HTML Code</strong></p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-sm-4"&gt;
          &lt;label class="Modallabel"&gt;Available Products:&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="col-sm-8"&gt;
          &lt;label id="Pro_chkbox" class="checkbox-inline"&gt;&lt;input name="check_list[]" type="checkbox" value="Cacao"&gt;Cacao&lt;/label&gt;
          &lt;label id="Pro_chkbox" class="checkbox-inline"&gt;&lt;input name="check_list[]" type="checkbox" value="Coconuts"&gt;Coconuts&lt;/label&gt;
          &lt;label id="Pro_chkbox" class="checkbox-inline"&gt;&lt;input name="check_list[]" type="checkbox" value="Bananas"&gt;Bananas&lt;/label&gt;&lt;br&gt;
          &lt;label id="Pro_chkbox" class="checkbox-inline"&gt;&lt;input name="check_list[]" type="checkbox" id="optcheck" value="Others"&gt;Others&lt;/label&gt;
          &lt;input type="text" id="Other_pro" name="otherproduct"&gt;&lt;br&gt;
          &lt;label id="Note"&gt;(Separate Products with commas)&lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>PHP Code</strong></p>
  
  <pre><code>$checked_count = count($_POST['check_list']);
  
      if ($checked_count &gt; 1)
      { 
          $productlist = implode(', ', $_POST['check_list']);
          echo $productlist;
      }
      elseif ($checked_count == 1)
      { 
          foreach($_POST['check_list'] as $selected) {
              $productlist = $selected;
  
              //To check if Others checkbox is checked or not to get the values in textbox
              if ($productlist == "Others")
              {
                  $productlist = $_POST["otherproduct"];
              }
              echo $productlist;
          }
      }
  </code></pre>