note 49209 deleted from function.preg-match-all by colder
| From: | colder@php.net | Date: | Mon, 16 Apr 2007 16:54:55 +0000 |
| Subject: | note 49209 deleted from function.preg-match-all by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125455@lists.php.net to get a copy of this message | ||
Note Submitter: MCLD
----
Here's a nice easy use for preg_match_all. I have data files in comma-separated-values format,
with all the data enclosed in quote marks. To convert one line of such a data file into an array:
function quotedCsvLineToArray($l)
{
preg_match_all('/(?<=,|\A)("(.*?)")?(?=,|\Z)/',$l, $matches,
PREG_PATTERN_ORDER);
return $matches[2];
}
hope it helps
dan