Skip to content

Commit

Permalink
Fixed issue #16672: Can't select seperator for CPDB export - export d…
Browse files Browse the repository at this point in the history
…oesn't recognise text (#1600)

Used 'fputcsv' in CPDBExport() with default args
  • Loading branch information
gabrieljenik committed Oct 2, 2020
1 parent 9e193f4 commit 311b453
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions application/helpers/export_helper.php
Expand Up @@ -2360,17 +2360,13 @@ function CPDBExport($data, $filename)
header("Content-Disposition: attachment; filename=".$filename.".csv");
header("Content-type: text/comma-separated-values; charset=UTF-8");
header("Cache-Control: must-revalidate, no-store, no-cache");
$tokenoutput = chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF'));
echo chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF')); // UTF-8 BOM

$handler = fopen('php://output', 'w');
foreach ($data as $key=>$value) {
foreach ($value as $values) {
$tokenoutput .= trim($values).',';
}
$tokenoutput = substr($tokenoutput, 0, -1); // remove last comma
$tokenoutput .= "\n";

fputcsv($handler, $value);
}
echo $tokenoutput;
fclose($handler);
exit;
}

Expand Down

0 comments on commit 311b453

Please sign in to comment.