parsecsv/parsecsv-for-php — pull request #26 by jimeh (2014-06-05 00:25:40+00:00)
Title: Fix last line parsing issue

This fixes #22.

If CSV data didn't end with `\n`, `\r`, or `\r\n` the last line of the CSV would be ignored, as the parser wouldn't trigger end of row logic for the last row.

This change forces the parser to process the end of the CSV data as it's own character (false), and deals with end of data just like it treats end of row. In theory this should be more memory efficient than appending a line feed to the CSV data if needed.

@williamknauss I'll let you code review this, as I'm not 100% confident these changes don't cause any side-effects.

I've done some basic hacky testing with the following inputs:

- `name,age\nJohn,28\nJenn,25`
- `name,age\nJohn,28\nJenn,25\n`
- `name,age\rJohn,28\rJenn,25`
- `name,age\rJohn,28\rJenn,25\r`
- `name,age\r\nJohn,28\r\nJenn,25`
- `name,age\r\nJohn,28\r\nJenn,25\r\n`

And they all produce the same output:

```
Array
(
[0] => Array
(
[name] => John
[age] => 28
)

[1] => Array
(
[name] => Jenn
[age] => 25
)

)
```

Additionally mixing the use of `\n`, `\r`, and `\r\n` within the same CSV data works just fine too.