我有以下代码,当我尝试$test_array
用“111 222”这样的空格打印下面数组中的值时:
$test_array= array('111', '222');
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Cache-Control: no-store, no-cache');
header('Content-Disposition: attachment; filename=data.csv');
$output = fopen('php://output', 'w');
$test_data = array(
array('Invoice #', 'Name', 'Email'),
array( $test_array, 'John', 'test@yahoo.com')
);
foreach( $test_data as $row )
{
fputcsv($output, $row, ',', '"');
}
fclose($output);