如果所有 csv 数据都在一行中,如何逐行获取 CSV 数据?
How to get CSV data line by line if all csv data comes in a sigle line?
我需要这个答案:
Array
(
[0] => Customer First Name
[1] => Customer Last Name
[2] => Date
[3] => Is Anonymous
[4] => Rating
[5] => Title
[6] => Review
[7] => EMail
)
Array
(
[0] => TODD
[1] => JACKMAN
[2] => 6/17/13
[3] => FALSE
[4] => 5
[5] => Outstanding service as always!
[6] => Outstanding service as always!
[7] => abc@al.com
)
Array
(
[0] => Gary
[1] => Peters
[2] => 6/19/13
[3] => FALSE
[4] => 5
[5] => From my description Ari suggested...
[6] => From my description Ari suggested what the problem might be. It was as he suspected. Got a replacement part at the best price. Installation was prompt and successful. Still one of the best places to go for auto repair.
[7] => abc@test.com
)
但我得到了:
Array
(
[0] => Customer First Name
[1] => Customer Last Name
[2] => Date
[3] => Is Anonymous
[4] => Rating
[5] => Title
[6] => Review
[7] => EMail
TODD
[8] => hjk
[9] => JACKMAN
[10] => 6/17/13
[11] => FALSE
[12] => 5
[13] => Outstanding service as always!
[14] => Outstanding service as always!
[15] => abc@al.com
Kliop
[16] => Gary
[17] => Peters
[18] => 6/19/13
[19] => FALSE
[20] => 5
[21] => From my description Ari suggested...
[22] => From my description Ari suggested what the problem might be. It was as he suspected. Got a replacement part at the best price. Installation was prompt and successful. Still one of the best places to go for auto repair.
[23] => abc@test.com
)
请帮帮我...
请尝试
$lines = file('test.csv');
foreach ($lines as $line_num => $line) {
$data = explode(',',$line);
echo "<pre>";print_r($data);
}
希望对您有所帮助
我需要这个答案:
Array
(
[0] => Customer First Name
[1] => Customer Last Name
[2] => Date
[3] => Is Anonymous
[4] => Rating
[5] => Title
[6] => Review
[7] => EMail
)
Array
(
[0] => TODD
[1] => JACKMAN
[2] => 6/17/13
[3] => FALSE
[4] => 5
[5] => Outstanding service as always!
[6] => Outstanding service as always!
[7] => abc@al.com
)
Array
(
[0] => Gary
[1] => Peters
[2] => 6/19/13
[3] => FALSE
[4] => 5
[5] => From my description Ari suggested...
[6] => From my description Ari suggested what the problem might be. It was as he suspected. Got a replacement part at the best price. Installation was prompt and successful. Still one of the best places to go for auto repair.
[7] => abc@test.com
)
但我得到了:
Array
(
[0] => Customer First Name
[1] => Customer Last Name
[2] => Date
[3] => Is Anonymous
[4] => Rating
[5] => Title
[6] => Review
[7] => EMail
TODD
[8] => hjk
[9] => JACKMAN
[10] => 6/17/13
[11] => FALSE
[12] => 5
[13] => Outstanding service as always!
[14] => Outstanding service as always!
[15] => abc@al.com
Kliop
[16] => Gary
[17] => Peters
[18] => 6/19/13
[19] => FALSE
[20] => 5
[21] => From my description Ari suggested...
[22] => From my description Ari suggested what the problem might be. It was as he suspected. Got a replacement part at the best price. Installation was prompt and successful. Still one of the best places to go for auto repair.
[23] => abc@test.com
)
请帮帮我...
请尝试
$lines = file('test.csv');
foreach ($lines as $line_num => $line) {
$data = explode(',',$line);
echo "<pre>";print_r($data);
}
希望对您有所帮助