title: Put texts from multiple files in an array and insert one by one in database
body: <p>I've a script for upload multiple text files from a folder on my computer in a &quot;multiple&quot; upload input form field, then read them and extract the content with file() function of php, once these contents have been retrieved in an array , here's what it looks like:</p>
  <p>Here's the result provided by the file() function</p>
  <pre><code>array
  (
       [0] =&gt; &quot;Here's the first content&quot;;
  )
  
  Array
  (
       [0] =&gt; &quot;Here's the second content&quot;;
  )
  </code></pre>
  <p>This way I can't fetch the content in a for loop, for that I tried to merge the two arrays into a multidimensional array like this example:</p>
  <pre><code>array
  (
  [0] =&gt; 'content one'
  [1] =&gt; 'content two'
  )
  </code></pre>
  <p>But I did not succeed</p>
  <p>Here's the code:</p>
  <pre><code>&lt;?php
  $pdo = require 'db_settings.php';
  
  if(isset($_POST['submit'])) {
  
      $line1 = $_FILES['file']['tmp_name'];
  
      foreach ($line1 as $value) {
          echo '&lt;pre&gt;';
          $r_content = file($value);
          
          $count = count($r_content);
       
          for ($i=0; $i &lt; $count ; $i++) { 
              
          try {
              $sql = &quot;INSERT INTO fill_wp (content) VALUES (:r_content)&quot;; 
              $stmt = $conn-&gt;prepare($sql);
              $stmt-&gt;bindValue(':r_content', $r_content[$i], PDO::PARAM_STR);
              $stmt-&gt;execute();
          
              exit();
                  
          }
          catch(PDOException $exception){
              die('ERROR: ' . $exception-&gt;getMessage());
          }
          
          }
  
          echo '&lt;/pre&gt;';
      }
  }
  </code></pre>