因此,我的代码使用PHP的内置fputcsv函数生成CSV文件
我的代码
$delimiter = ';';
$filename = "members_" . date('Y-m-d') . ".csv";
//create a file pointer
$f = fopen('php://memory', 'w');
//set column headers
$fields = array('"FK"','"ID"', '"Name"', '"Email"', '"Phone"', '"Created"');
fputcsv($f, $fields, $delimiter, ' ');
//move back to beginning of file
fseek($f, 0);
//set headers to download file rather than displayed
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="' . $filename . '";');
//output all remaining data on a file pointer
fpassthru($f);
// }
exit;
输出:
FK;"ID";"Name";"Email";"Phone";"Created"
但我想要
"FK";"ID";"Name";"Email";"Phone";"Created"
请帮助我