Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dvdfreitas's avatar

Strange error

Hi,

I have a csv file with the following header:

email;username;name;full_name;email_verified;password;profile_photo_path;group;sex

With the following code:

$file = fopen($filename, "r");
$header_csv = fgets($file);
dd($header_csv);

I get (note the space between e and mail):

"e mail;username;name;full_name;email_verified;password;profile_photo_path;group;sex\r\n"

If I change the word email to another one, the same problem occurs. Example: name --> n same

Can someone has an idea why this happens?

Thanks

0 likes
1 reply
dvdfreitas's avatar
dvdfreitas
OP
Best Answer
Level 18

Found the "solution". It has to do with the codification of the file. I had to save it in UTF-8. Previously it was saved as UTF-8 with BOM.

Please or to participate in this conversation.