Forum Moderators: coopster

Message Too Old, No Replies

Find a random string

         

popepiusx2

2:12 pm on Apr 18, 2008 (gmt 0)

10+ Year Member



I'm looking for a way to process a URL. Basically, it's an Invision Board url and I'm looking to take that url and process it. So for example if the URL is http://www.example.com/index.php?showforum=1&s=1856473546375647&topic=84092 , I need to take out the s=1856473546375647 . However, this is a dynamically generated 16 character session ID so I need to know how to make PHP look for s=#*$!#*$!#*$!#*$!#*$!x and remove it. Any ideas?

[edited by: dreamcatcher at 6:34 am (utc) on April 19, 2008]
[edit reason] Use example.com, thanks. [/edit]

d40sithui

3:44 pm on Apr 18, 2008 (gmt 0)

10+ Year Member



i think this is a preg_replace() issue.

<?

//default string
$url = "http://www.site.com/index.php?showforum=1&s=1856473546375647&topic=84092 ";
echo "\$url before: $url<br>\n";

//what will replace the s=##...
$replace = "";

//using preg_replace to do it
$url = preg_replace("/\&s=[0-9]{1,}/", $replace, $url);

//final string
echo "\$url after: $url<br>\n";
?>

popepiusx2

1:54 pm on Apr 21, 2008 (gmt 0)

10+ Year Member



That's the solution, thank you very much.