我有一个$events
看起来像的数组
Array
(
[0] => Array
(
[4fe8a21c6f05d60023009d96] => any authentication
)
[1] => Array
(
[4fe8a21c6f05d60023009d96] => any authentication
)
[2] => Array
(
[4fe8a21c6f05d60023009d96] => any authentication
)
[3] => Array
(
[4fe8a21c6f05d60023009d96] => any authentication
)
[4] => Array
(
[4fe8a21c6f05d60023009d96] => any authentication
)
我正在使用下面的代码尝试在 CSV 的每一行中放置 user_id 和“任何身份验证”字样。但是,使用我的代码,我看到以下内容(而不是"4fe8a21c6f05d60023009d96 " "any authentication"
):
"User_ID " " Event"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
"Array " " Array"
我的代码是:
$fp = fopen('events.csv', 'w');
$header = array('User_ID',",",'Event');
fputcsv ($fp, $header, "\t");
foreach ($events as $event) {
$line = array(array_keys($event),',',$event);
fputcsv($fp, $line,"\t");
}
fclose($fp);