這很奇怪PHP將我的Excel生成的CSV文件讀取到一行中。代碼是:PHP將csv數據讀入一行代碼
if ($file) {
while (($line = fgets($file)) !== false) {
print '<div>'.$line.'</div>'."<br/>";
}
} else {
// error opening the file.
}
fclose($file);
CSV
Name, City
Jon,Paris
Doe,Madrid
你可以嘗試我的CSV解析器(特別適用於大數據和逐行):https://github.com/DeepVarvar/PHP-CSV-Parser-Writer/blob/master/examples/parse-from-file-與完成,options.php – Deep