I already managed to split the CSV file using this regex: \"/,(?=(?:[^\\\"]\\\"[^\\\"]\\\")(?![^\\\"]\\\"))/\"
But I ended up with an array of stri
For those of you who wan't to use regex instead of fgetcsv. Here is a complete example how to create a html table from csv using a regex.
$data = file_get_contents('test.csv');
$pieces = explode("\n", $data);
$html .= "\n";
foreach (array_filter($pieces) as $line) {
$html .= "\n";
$keywords = preg_split('/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/', $line,-1,PREG_SPLIT_DELIM_CAPTURE);
foreach ($keywords as $col) {
$html .= "".trim($col, '"')." \n";
}
$html .= " \n";
}
$html .= "
\n";