note 47021 deleted from function.fgetcsv by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 18:18:46 +0000 |
| Subject: | note 47021 deleted from function.fgetcsv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155100@lists.php.net to get a copy of this message | ||
Note Submitter: mickoz[at]parodius[dot]com
----
In "php at dogpoop dot cjb dot net" post, I would change in his function:
function csv_split($line,$delim=',',$removeQuotes=true)
this code:
if ($line[$i+1] == '"') {
to:
if ($i+1 < strlen($line) && $line[$i+1] == '"') {
The reason is that if the quote (") is at the last line of the string, then it will try to
reach an undefined space in the string, therefore giving a PHP error.
Of course his function is great if your line is a true compatible csv line, but I leave that to you
to judge if you can do this assumption ;-)