note 45358 deleted from function.substr-count by nlopess

From: Date: Thu, 23 Jun 2005 19:59:46 +0000
Subject: note 45358 deleted from function.substr-count by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90857@lists.php.net to get a copy of this message
Note Submitter: McAjvar ---- 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 :)

« previous php.notes (#90857) next »