title: CodeIgniter - Writing input array to database
body: <p>I am trying to grab the data from an array of input fields and write them to a database. I have never worked with arrays before but this is the code I have. It is based off what I would do if it was just a single input value. I know this is wrong but I have no idea what to try next. Any ideas? Thanks.</p>
  
  <pre><code>//view
  &lt;input type="text" name="assignments[]"&gt;
  &lt;input type="text" name="hours[]"&gt;
  
  &lt;input type="text" name="assignments[]"&gt;
  &lt;input type="text" name="hours[]"&gt;
  
  &lt;input type="text" name="assignments[]"&gt;
  &lt;input type="text" name="hours[]"&gt;
  
  &lt;input type="text" name="assignments[]"&gt;
  &lt;input type="text" name="hours[]"&gt;
  
  &lt;input type="text" name="assignments[]"&gt;
  &lt;input type="text" name="hours[]"&gt;
  
  //controller
  $assignments = $this-&gt;input-&gt;post('assignments', TRUE);
  $hours = $this-&gt;input-&gt;post('hours', TRUE);
  
  $this-&gt;load-&gt;model('create', 'create_model');
  $this-&gt;create_model-&gt;create_projects($assignments, $hours);
  
  //model
  public function create_projects($assignments, $hours) {
  
      $data = array(
          'assignments' =&gt; $assignments,
          'hours' =&gt; $hours,
          );
      $this-&gt;db-&gt;insert('projects', $data);
  }
  </code></pre>