我有类似使用fputcsv创建的字符串
Date,Name,Hours 2013-01-02,"Test User",7:59 2013-01-03,"Test User",7:53 2013-01-04,"Test User",8:12 2013-01-07,"Test User",7:56 2013-01-08,"Test User",8:25 2013-01-09,"Test User",7:56 2013-01-10,"Test User",8:10 2013-01-11,"Test User",7:53 2013-01-14,"Test User",7:54 2013-01-15,"Test User",0:34 2013-04-01,"Test User",5:51 2013-04-02,"Test User",8:50 2013-04-03,"Test User",7:25 2013-04-04,"Test User",8:3 2013-04-05,"Test User","10:42:52[Not punch out]" ,Total,103:1
当设置正确的标题 (header('Content-type: application/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"');) 时,它会提供正确的 csv 文件。
但是我希望再次将此字符串转换为数组格式,所以我尝试将上面的字符串传递给str_getcsv但得到这样的数组
Array
(
[0] => Date
[1] => Name
[2] => Hours
2013-01-02
[3] => "Allen Herrera"
[4] => 7:59
2013-01-03
[5] => "Allen Herrera"
[6] => 7:53
2013-01-04
[7] => "Allen Herrera"
[8] => 8:12
2013-01-07
[9] => "Allen Herrera"
[10] => 7:56
2013-01-08
[11] => "Allen Herrera"
[12] => 8:25
2013-01-09
[13] => "Allen Herrera"
[14] => 7:56
2013-01-10
[15] => "Allen Herrera"
[16] => 8:10
2013-01-11
[17] => "Allen Herrera"
[18] => 7:53
2013-01-14......................
您能帮我获得正确格式化的数组,以便我可以轻松地使用它在数组上创建表循环。