我们在wordpress插件中使用此类型代码创建时间但不起作用。
$data = array(
'0' => array('Name'=> 'user1', 'Status' =>'complete', 'Priority'=>'Low', 'Salary'=>'001'),
'1' => array('Name'=> 'user2', 'Status' =>'inprogress', 'Priority'=>'Low', 'Salary'=>'111'),
'2' => array('Name'=> 'user3', 'Status' =>'hold', 'Priority'=>'Low', 'Salary'=>'333'),
'3' => array('Name'=> 'user4', 'Status' =>'pending', 'Priority'=>'Low', 'Salary'=>'444'),
'4' => array('Name'=> 'user5', 'Status' =>'pending', 'Priority'=>'Low', 'Salary'=>'777'),
'5' => array('Name'=> 'user6', 'Status' =>'pending', 'Priority'=>'Low', 'Salary'=>'777')
);
此类型数组管理然后
$filename = "exportpin".time().".csv";
$fp = fopen('php://output', 'w');
$header = array('name','Status', 'Priority','Salary');
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
fputcsv($fp, $header);
foreach($item_array as $datas) {
fputcsv($fp, $datas);
}
exit;
此类型错误获取
Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\pinrotate\wp-includes\formatting.php:4596)