note 75471 added to function.split
| From: | NateSweet at osu1 dot php dot net | Date: | Thu, 31 May 2007 20:39:45 +0000 |
| Subject: | note 75471 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127088@lists.php.net to get a copy of this message | ||
This function takes a string like this...
this=cool that="super cool" thing='ridiculous cool'
And gives you an associative array of names and values.
function parseNameValues ($text) {
$values = array();
if (preg_match_all('/([^=\s]+)=("(?P<value1>[^"]+)"|' .
'\'(?P<value2>[^\']+)\'|(?P<value3>.+?)\b)/', $text, $matches,
PREG_SET_ORDER))
foreach ($matches as $match)
$values[trim($match[1])] = trim(@$match['value1'] . @$match['value2'] .
@$match['value3']);
return $values;
}
(regex broken into two strings so it won't be too long for this webpage)
----
Server IP: 64.71.164.2
Probable Submitter: 207.225.248.36
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit -- https://master.php.net/note/edit/75471
Del: integrated -- https://master.php.net/note/delete/75471/integrated
Del: useless -- https://master.php.net/note/delete/75471/useless
Del: bad code -- https://master.php.net/note/delete/75471/bad+code
Del: spam -- https://master.php.net/note/delete/75471/spam
Del: non-english -- https://master.php.net/note/delete/75471/non-english
Del: in docs -- https://master.php.net/note/delete/75471/in+docs
Del: other reasons-- https://master.php.net/note/delete/75471
Reject -- https://master.php.net/note/reject/75471
Search -- https://master.php.net/manage/user-notes.php