我有以下内容:
$name = 'registrations.csv';
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename='. $name);
header('Pragma: no-cache');
header("Expires: 0");
$outstream = fopen("php://output", "w");
$results = mysql_query("select * from registrations");
while( $result = mysql_fetch_array($results) )
{
fputcsv($outstream, $result);
}
fclose($outstream);
这很好用,除了它给每列两个。例如,我在表中有一个 given_name 列和一个 surname 列。生成的 csv 文件将每列显示两次。为什么?