csvreader library issue with importing to database

I am using the csvreader library to import a .csv file into a database, but having issues with commas inside double quotes.

The csvreader is set to this:
var $fields; /** columns names retrieved after parsing */
var $separator = ';'; /** separator used to explode each line */
var $enclosure = '"';

With an example:

My items in the row are not separated by a semi-colon, but replacing the separator with a comma severely screws things up. When I keep the semi-colon in place, I get issues because not every field in the line is encapsulated by double-quotes.

foreach($data['csvData'] as $row)
foreach ($row as $item)
$item=explode(",", $item);
$results_array = array(
'id' => $item[1],
'column_2' => $item[2],
etc etc.

A line from the csv file: 1, "value 1, value 2, value 3", something, something else

The explode function then messes up the database insert, causing 'value 2' to be inserted where 'something' should be.
I understand why this is happening, but I can't figure out how to remove the commas from inside the double quotes, or at least ignore them.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.