This has probably already been asked many times before, but a search of the archives didn't help.
I'm trying to import a comma delimited text file, process it and then enter the data into a MySQL database. Each field is enclosed in double quotes.
The code works well until it comes across a field that has a comma embedded with in the double quotes. Is there a quick fix?
$data=file($upfile);
for ($record_num=0; $record_num<count($data); $record_num++)
{
$rawfield=explode(",",$data[$record_num]);
for ($field_num=0; $field_num<count($rawfield); $field_num++)
{
$field[$field_num]=str_replace("\"","",$rawfield[$field_num]); // remove quotes from each field
}
// sql stuff here
}