如何让PHP的fgetcsv()识别Classic Mac(CR)新行字符?

我使用此代码从CSV文件中获取列数:

$this->dummy_file_handler = fopen($this->config['file'],'r');
if ($dataset =fgetcsv($this->dummy_file_handler))
{
    $this->number_of_columns = count($dataset);
}

除非文件是使用Excel for Mac 2011导出的,否则它工作正常,因为新行字符是经典Mac(CR),fgetcsv无法识别.

如果我手动将换行符从Classic Mac(CR)更改为Unix(LR),那么它可以工作,但我需要将其自动化.

如何让fgetcsv识别经典Mac(CR)新行字符?

manual

Note: If PHP is not properly
recognizing the line endings when
reading files either on or created by
a Macintosh computer, enabling the
auto_detect_line_endings run-time
configuration option may help resolve
the problem.

翻译自:https://stackoverflow.com/questions/4759880/how-can-i-make-phps-fgetcsv-to-recognize-the-classic-mac-cr-new-line-charac

转载注明原文:如何让PHP的fgetcsv()识别Classic Mac(CR)新行字符?