I’m working with PHP and CSV files exported from Excel.
My script to read the lines is as follows:
$lineseparator = "\r\n";
$csvcontent = fread($file,$size);
fclose($file);
foreach(explode($lineseparator,$csvcontent) as $line) {
print $line."END<br>";
}
However, it doesn’t recognised the new lines. If I use a proper symbol such as ; it does. I want to make this as easy as possible for the used, so they can export it from Excel. The trouble is Excel just exports it with new lines instead of symbols.
Why isn’t this picking up the new line characters?
If it’s a CSV file, you should really be using fgetcsv instead.