您好,我有一个fgetcsv函数,它可以读取CSV文件并将数据导出到列表中。这是有效的,我已经在其他地方多次使用这个函数,没有任何问题。
代码的相关部分是:
ini_set("auto_detect_line_endings", true);
$file = fopen($_FILES['filename']['tmp_name'],"r");
while (($data = fgetcsv($file, 1000, ",")) !== FALSE)
{
$body_data['user_list'][] = $data;
}
fclose($file);问题是读取CSV会在分栏数据中单词之间的任何空格(空白)处停止。
我以为auto_detect_line_endings会解决这个问题,会不会是这导致了这个问题?
发布于 2012-10-16 19:08:55
用下面的代码改变你的while循环
while (!feof($file) ) {
$body_data['user_list'][] = fgetcsv($file, 1024);
}https://stackoverflow.com/questions/12913256
复制相似问题