fgetcsv() ignores special characters when they are at the beginning of line!

前端 未结 4 1801
误落风尘
误落风尘 2020-12-10 14:14

I have a simple script that accepts a CSV file and reads every row into an array. I then cycle through each column of the first row (in my case it holds the questions of a s

4条回答
  •  我在风中等你
    2020-12-10 14:48

    Have you already checked out the manual page on fgetcsv? There is nothing talking about that specific problem offhand, but a number of contributions maybe worth looking through if nothing comes up here.

    There's this, for example:

    Note: Locale setting is taken into account by this function. If LANG is e.g. en_US.UTF-8, files in one-byte encoding are read wrong by this function.

    Also, seeing as it's always in the beginning of the line, could it be that this is really a hidden line break problem? There's this:

    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.

    You may also want to try saving the file with different line endings.

提交回复
热议问题