note 49209 added to function.preg-match-all
| From: | MCLD at osu1 dot php dot net | Date: | Thu, 20 Jan 2005 10:35:51 +0000 |
| Subject: | note 49209 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83663@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49209
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49209&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49209&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49209&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49209&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49209&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49209&report=yes
Search -- http://master.php.net/manage/user-notes.php