title: Codeigniter Array to Database with foreach
body: <p>I'm trying to store details about uploaded files in the DB.</p>
  
  <p>Presently details of single uploaded files go into an array. I have no idea on how I should write this info into the DB.</p>
  
  <p>I think this must be done using a foreach loop with the array but I'm not sure how to do this.</p>
  
  <p>Please advise.</p>
  
  <p>My model looks like this:</p>
  
  <pre><code>class download_model extends CI_Model {
  
      //
      // Add file
      public function add() {
          $new_file = array(
              'file_author_id'            =&gt;  $this-&gt;profil_model-&gt;get_user_id(),
              'file_author_name'          =&gt;  $this-&gt;profil_model-&gt;get_firstname().' '.$this-&gt;profil_model-&gt;get_lastname(),
              'file_name'                 =&gt;  $this-&gt;input-&gt;post('file_name'), &lt;-- IN THIS I MUST RUN LOOP TO SEND MULTIPLE VALUES- I HAVE NO IDEA HOW I CAN DO THIS :(
          );
          $this-&gt;db-&gt;insert('download', $new_file);
      }
  }
  </code></pre>
  
  <p>This is my upload file(s) result:</p>
  
  <pre><code>Array
  (
      [pageTitle] =&gt; Multiple file upload
      [uploads] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [file_name] =&gt; MY_FILE_NAME.txt
                      [file_type] =&gt; text/plain
                      [file_path] =&gt; DIR
                      [full_path] =&gt; DIR/MY_FILE_NAME.txt
                      [raw_name] =&gt; MY_FILE_NAME
                      [orig_name] =&gt; MY_FILE_NAME.txt
                      [client_name] =&gt; MY_FILE_NAME.txt
                      [file_ext] =&gt; .txt
                      [file_size] =&gt; 0.98
                      [is_image] =&gt; 
                      [image_width] =&gt; 
                      [image_height] =&gt; 
                      [image_type] =&gt; 
                      [image_size_str] =&gt; 
                  )
  
              [1] =&gt; Array
                  (
                      [file_name] =&gt; MY_FILE_NAME_2.txt
                      [file_type] =&gt; text/plain
                      [file_path] =&gt; DIR
                      [full_path] =&gt; MY_FILE_NAME_2.txt
                      [raw_name] =&gt; MY_FILE_NAME_2
                      [orig_name] =&gt; MY_FILE_NAME_2.txt
                      [client_name] =&gt; MY_FILE_NAME_2.txt
                      [file_ext] =&gt; .txt
                      [file_size] =&gt; 0.98
                      [is_image] =&gt; 
                      [image_width] =&gt; 
                      [image_height] =&gt; 
                      [image_type] =&gt; 
                      [image_size_str] =&gt; 
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Please, help me or do anything how I can do this :( It's possible to do :( ?</p>