Page 1 of 1

How to replace a parameter in sitring?

Posted: Tue Apr 24, 2007 12:23 pm
by Bizzy
Hey guys, it might be dumb question for you, but huge problem for me.

If I have for example:

Code: Select all

$newBrand = "nike";
$question = "/?brand=adidas&size=M";
How should I set new "brand" and get $question in same format?

Thanks.

Posted: Tue Apr 24, 2007 12:41 pm
by Christopher
You could use something like preg_replace() to replace everything between 'brand=' and '&'. Or you could explode() on '&' and then '=' and then reassemble. There are probably a couple other ways to do it as well.