S
S
Sergey Semin2017-08-23 11:16:11
PHP
Sergey Semin, 2017-08-23 11:16:11

Why when saving to csv (using php) quotes are replaced with " How to fix it?

I save the data in the csv file, in the name field there are double quotes "but they are replaced by" , how to fix it?
With the help of fputcsv the same problem.
The code is extremely simple

public function getcsv($array, $filename = "export.csv", $delimiter=";") { 
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="'.$filename.'";');

        foreach ($array as $line) {  
                  echo $line['order_id'].';'.$line['model'].';'.$line['quantity'].';'.$line['price'].';'.$line['skidka'].';'.$line['shipping'].';'. $line['name']."\n";
        }
}

in the field $line['name'] - there is the name of the product OGONEK. COLLECTION "HOUSE"
in csv turns out like this FIRE. COLLECTION "HOUSE"
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Gadzhiev, 2017-08-23
@korund89


in the field $line['name'] - there is the name of the product OGONEK. COLLECTION "HOUSE"
in csv turns out like this FIRE. COLLECTION "HOUSE"
What is the difference? Didn't see it with my eyes...

S
Sergey Semin, 2017-08-23
@korund89

apparently not to be skipped here & quot; replaces
FLIGHT with quotation marks. COLLECTION " HOUSE" - added spaces

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question