-1

I get a problem with symbols if i want to create a CSV. I get a  symbol. I think it is a space, but so as you can see i already added charset=UTF-8 to try to fix this problem.

 $lines[] = array($product_sku, $product_name, $product_discount, $product_price, $product_quantity, $product_price_total);

header('Content-Encoding: UTF-8');
header("Content-type: text/csv; charset=UTF-8");
header('Content-Disposition: attachment; filename="filename";');

echo "\xEF\xBB\xBF";

$f = fopen('php://output', 'wb');

// First row
fputcsv($f, array('SKU', 'Productnaam', 'Discount', 'Prijs', 'Aantal', 'Totaal prijs'), $delimiter);

foreach ($lines as $line) {
    fputcsv($f, $line, $delimiter);
}

// Close the file
fclose($f);
TDwebdev
  • 1
  • 3

1 Answers1

0

The fix was add: echo "\xEF\xBB\xBF"; // UTF-8 BOM under the CSV headers

TDwebdev
  • 1
  • 3