I can’t see this mentioned in the description, but it appears that the fields will be trimmed slightly of trailing line breaks.
In the following example:
<?php
$string = "\nPHP\r\n,Java\nScript\r\n\r\n,Fortran\n,Cobol\n\n,\nSwift\r\n\r\n\r\n";
$data = str_getcsv($string);
foreach($data as $d) print "[$d]";
?>
You’ll see:
- a leading line break is retained; a line break in the rest of the field is also retained
- one trailing line break is removed; any more are retained
- a line break at the end of the string is also removed; this means that two trailing line breaks at the end are removed
- a line break can be a unix/macos line break (\n) or a windows line beak (\r\n)
Tested on my Macintosh, so I’m not sure how universal this is.
Among other things, it means you can read the file with the file() function without having to include the FILE_IGNORE_NEW_LINES flag.