So, my code generates a CSV file using PHP\'s built-in fputcsv function.
For the delimiter, I use \',\' (a comma). For the enclosure, I use \'
\',\'
\'
Any reason you can't str_replace(',,',',"",',$output); ? You'd also have to see if the last or first character is a comma and if so, replace the comma with ,""