Read a csv file and insert into DB table
What I found to greatly improves the speed of insert queries, is inserting multiple rows using a single query. You seems to have found the same solution, but it is implemented in a very roundabout way.
Your code could also benefit a lot from using functions. So, let's start with the most important one: How to insert multiple rows. It could look something like this:
function insertRows($db, $table, $rows)
{
    $values    = '(' . implode(',', array_fill(0, count($rows[0]), '?')) . ')';
    $query     = 'INSERT INTO '.$table . ' VALUES ' .
                 implode(',', array_fill(0, count($rows), $values));
    $statement = $db-&gt;prepare($query);
    $index     = 1;
    foreach($rows as $row) {
        foreach($row as $value) {
            $statement-&gt;bindValue($index++, $value);
        }    
    }
    $statement-&gt;execute();
}

This bit of code has only one function: Insert a certain number of rows into the database as quickly as possible. This function doesn't read data, change it in any way, but it does use parameter binding for extra security. That's probably not needed in this case, but it also doesn't hurt. No more problems with quotes.
You can insert quite a few rows using this function, somewhere around 50 to 150 rows, depending on what your input looks like. Above a certain number the speed simply won't increase anymore, so there's no point in going to extremely large number of rows.
I would create another function for changing the row data from the format you received to the format you want to insert:
function reformatRow($row)
{
    // &lt;...put your code here...&gt;
    return $row;
}

We can now also implement a function that does the above for multiple rows:
function reformatRows($rows)
{
    foreach ($rows as $key =&gt; $row) {
        $rows[$key] = reformatRow($row);
    }
    return $rows;
}

Functions don't have to be complex to be useful. I actually will not use this function, but I thought it was nice to show it.
All that's now left to do is to read the input, so let's do that. I will use parts of your code:
const MAX_ROWS = 100;

fgetcsv($handle, 2000, &quot;;&quot;, chr(8)); // read header and dump it

$rows = [];
while (($row = fgetcsv($handle, 2000, &quot;;&quot;, chr(8))) !== FALSE) {
    $rows[] = reformatRow($row);
    if (count($rows) &gt;= MAX_ROWS) {
        insertRows($db, $table[$i], $rows);
        $rows = [];
    }
}

if (count($rows) &gt; 0) {
    insertRows($db, $table[$i], $rows);
}

I haven't fully tested all this code.
I also don't think this code will be any quicker than yours. There's also no way for me to test any optimization, since I don't have your data, so I'm afraid I can't help you there. Reading data into a database just takes time. It is possible that fgetcsv() is not the optimal way to read a big CSV file, but I haven't tested that.
What I have tried to make clear is that by splitting your code into functional parts it become easier to understand, and more reusable. The insertRows() is, for instance, is, partly, reused from my own code. Once you've written a function like that, and it works, you can reuse it everywhere.