Mit diesem Code erstelle ich meine CSV-Exportdatei:fputcsv() hinzufügen Anführungszeichen zu jedem Eintrag?
foreach ($data_for_export as $row) {
$data = [];
array_push($data, $row->product_id);
array_push($data, $row->product_name);
array_push($data, $row->product_code);
array_push($data, $row->text);
fputcsv($file, $data);
}
fclose($file);
Beispiel Ausgabe lautet:
2131,"Toys set 35", TSSET35, "Lorem ipsum dolor sit amet"
Ich versuchte es mit:
preg_replace("/([a-z0-9]+)/i", '"$1"', $row->product_id)
'"'.$row->product_id.'"'
Mit "preg_replace" erhalte ich einige Male mehr Zitate dann benötigt ...
Ich brauche dort Zitate auf a lle Exportartikel, wie kann ich das machen?
Warum sind Zitate auf alle Artikel eine Anforderung? CSV benötigt es nicht als solches, weshalb PHP keine Artikel hinzufügt, die es nicht benötigen. – deceze
@deceze es ist Kundenanforderung :( – Caner