title: Get multiple values of checkbox in codeigniter
body: <p>I am currently doing a project. I have a checkbox( where the user will choose type of services provided by the company). When I try to post the service that was selected(for example 2 services is checked) in my controller, I am only getting one service. The question is how can I get the multiple values in my checkbox?</p>
  
  <p>Note: I also tried to use foreach within my controller, I am getting some error like "Invalid argument supplied for foreach()".</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;label&gt;Desired Service&lt;/label&gt; &lt;br&gt;
  &lt;?php foreach($services as $s):?&gt;
  &lt;label&gt;&lt;input type="checkbox" name="service_name[]" value="&lt;?= $s-&gt;service_name?&gt;"&gt;&lt;?= $s-&gt;service_name?&gt;&lt;/label&gt;
  &lt;br&gt; 
  &lt;?php endforeach?&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>$this-&gt;form_validation-&gt;set_error_delimiters('&lt;div class="alert alert-danger" role="alert"&gt;', '&lt;/div&gt;');
      $this-&gt;form_validation-&gt;set_rules('full_name', 'Fullname', 'required');
      $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'required');
      $this-&gt;form_validation-&gt;set_rules('contact', 'Contact', 'required');
      $this-&gt;form_validation-&gt;set_rules('date', 'Date', 'required');
      $this-&gt;form_validation-&gt;set_rules('address', 'Address', 'required');
      $this-&gt;form_validation-&gt;set_rules('zip_code', 'Zip Code', 'numeric|required');
      $this-&gt;form_validation-&gt;set_rules('province', 'Province', 'required');
      $this-&gt;form_validation-&gt;set_rules('date', 'Date', 'required');
      $this-&gt;form_validation-&gt;set_rules('service_name', 'Service', 'required');
      if ($this-&gt;form_validation-&gt;run() == FALSE) {
          $this-&gt;index();
      } 
      else {
          $service_name = implode(', ', $_POST['service_name']);
          $event = array(
          'full_name' =&gt; $this-&gt;input-&gt;post('full_name'),
          'email' =&gt; $this-&gt;input-&gt;post('email'),
          'contact' =&gt; $this-&gt;input-&gt;post('contact'),
          'address' =&gt; $this-&gt;input-&gt;post('address'),
          'zip_code' =&gt; $this-&gt;input-&gt;post('zip_code'),
          'state_province' =&gt; $this-&gt;input-&gt;post('province'),
          'date' =&gt; $this-&gt;input-&gt;post('date'),
          'service' =&gt; $service_name
  
          );
          $this-&gt;EventModel-&gt;add_event($event);
          echo "&lt;script&gt;
          window.alert('Your Desired Date is being Proccessed!');
          location.href = '".site_url('/')."';
          &lt;/script&gt;";
      }
  </code></pre>