我在phpmyadmin中有数据,例如:(第一行是标题)
||from||to||messages||
||john||andy||meeting now||
||dony||sherly||Place in \"Jakarta\" , Indonesia, 15412
当我通过phpmyadmin版本3.5.6导出到csv时,我得到了这个csv文件:
"from","to","messages"
"john","andy","meeting now"
"from","to","Place in \""Jakarta\"" , Indonesia, 15412"
如果我使用此代码
<?php
// code start
$file = fopen($path, 'r');
while (($line = fgetcsv($file)) !== FALSE) {
print_r($line);
}
fclose($file);
// code end
?>
我希望得到这个
//output start
Array
(
[0] => from
[1] => to
[2] => messages
)
Array
(
[0] => john
[1] => andy
[2] => meeting now
)
Array
(
[0] => dony
[1] => sherly
[2] => Place in \"Jakarta\" , Indonesia, 15412
)
//output end
但我得到了
//output start
Array
(
[0] => from
[1] => to
[2] => messages
)
Array
(
[0] => john
[1] => andy
[2] => meeting now
)
Array
(
[0] => from
[1] => to
[2] => Place in \"Jakarta\""
[3] => Indonesia
[4] => 15412"
)
//output end
任何人都可以帮助解决此错误吗?
答案 0 :(得分:0)
你有双引号。
"from","to","Place in \""Jakarta\"" , Indonesia, 15412"
应该是
"from","to","Place in \"Jakarta\" , Indonesia, 15412"