note 45358 added to function.substr-count
| From: | McAjvar at osu1 dot php dot net | Date: | Fri, 03 Sep 2004 10:15:29 +0000 |
| Subject: | note 45358 added to function.substr-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75977@lists.php.net to get a copy of this message | ||
this is a small correction of bpotter's code:
if (substr_count($QUERY_STRING, '&') > 0) {
$QUERY_STRING = str_replace('&', '&', $QUERY_STRING);
$queryArray = explode('&',$QUERY_STRING);
foreach ($queryArray as $queryItem) {
$querySegment = explode("=",$queryItem,2);
list ($key, $val) = $querySegment ;
if ($val)
$$key = $val;
}
}
explanation: these corrections do not replace
file.php?var1=using winamp; others suck&var2=1+1=2&var3=mongolia
into
file.php?var1=using win others suck&var2=1+1=2&var3=mongolia
but rather into
file.php?var1=using winamp; others suck&var2=1+1=2&var3=mongolia
also, the when having values which also contain '=', the parameter 2 in explode ()
prevents it into splitting it in more than 2 values. so $var2 isn't an array ('1+1',
'2') but rather has the value '1+1=2'
hope this helps :)
----
Manual Page -- http://www.php.net/manual/en/function.substr-count.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45358
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45358&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45358&report=yes
Search -- http://master.php.net/manage/user-notes.php