Re: Function Request: csv_explode()
| From: | Edin Kadribasic | Date: | Wed, 05 Dec 2001 10:57:26 +0000 |
| Subject: | Re: Function Request: csv_explode() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72567@lists.php.net to get a copy of this message | ||
On Wed, 5 Dec 2001, Stig S. Bakken wrote:
> Splitting a CSV string into an array could be done like this too:
>
> $fields = explode('","', trim($string, '"'));
I've had problems with CSV files exported from Excel that does not quote
all fields, escapes double quotes with double quotes and puts newlines in
the middle of a field:
45,"Test ""field"",
with several lines"
This should be decoded as a two field record:
45
Test \"field\",\nwith several lines
So a I'm afraid that a simple split() wouldn't be able to cope with all
that.
Edin