On Thu, Nov 27, 2003 at 01:20:57PM +0400, Sheni R. Meledath wrote:
:
: Could anybody help me to create a regular expression to remove a pattern
: from a string.
:
: $querystring =
http://10.100.1.7/cdms/prfl.phtml?action=search&custtype=1&gender=&x=22&y=10&page=2
:
: I would like to remove "&page=2" from this query string. The page number
: changes. That is the reason why I want to use regular expression to replace
: the variable & value from the string.
$qstring = preg_replace('/&?page=\d*/i', '', $querystring);
: Now I am using this option to remove the variable name only, so that it
: will not collide with the variable value that is submitted again.
Instead of using regexps on the URL, it might be easier (and safer) to
loop through $_GET, build a new $geturl array, add/delete/change any
variables in $geturl, then build a new $geturlstr string that can then
be appended to your hyperlinks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php