title: Codeigniter Insert Array to Database
body: <p>I have created a form in Codeigniter with a phone number field that dynamically is duplicated using javascript. So basically I can have one or more fields like this.</p>
  
  <pre><code>&lt;input name="phone[]" value=""type="text"&gt;
  &lt;input name="phone[]" value=""type="text"&gt;
  </code></pre>
  
  <p>Then in my controller I have </p>
  
  <pre><code>$form_data = array(
      'first_name' =&gt; $this-&gt;input-&gt;post('first_name'),
      'last_name' =&gt; $this-&gt;input-&gt;post('last_name'),
      'phone' =&gt; $this-&gt;input-&gt;post('phone[]')
      );
  </code></pre>
  
  <p>Then I am saving this to my dabase like so</p>
  
  <pre><code>function SaveForm($form_data)
  {
      $this-&gt;db-&gt;insert('customers', $form_data);
      if ($this-&gt;db-&gt;affected_rows() == '1')
      {
          return TRUE;
      }
      return FALSE;
  }
  </code></pre>
  
  <p>but obviously the code for 'phone' is wrong,  I just cant figure out how to properly do this.</p>