Need a PHP function that replaces parameter in URLs, if availabe - otherwise adds it
I need help with following problem.

I am having a PHP script, which is handling URLs. Now I want to add the following function:

1. If URL contains example.com or www.example.com, check for var1=$random$
2. If var1=$random$ exists, replace $random$ with val2
3. If var1=$random$ does not exist, add var1=val2
4. Jump to next URL (nextexample.com/www.nextexample.com) and do steps 1-3
5. If no matching URL has been found, proceed with the rest of the functions

Please note, that $random$ would really be random, because I don't know, what the value of the var could be.

I'm really not getting forward with this and it would be nice, if anyone could help! :)

Cheers,
J
Need a PHP function that replaces parameter in URLs, if availabe - otherwise adds it
===

I need help with following problem.

I am having a PHP script, which is handling URLs. Now I want to add the following function:

1. If URL contains example.com or www.example.com, check for var1=$random$
2. If var1=$random$ exists, replace $random$ with val2
3. If var1=$random$ does not exist, add var1=val2
4. Jump to next URL (nextexample.com/www.nextexample.com) and do steps 1-3
5. If no matching URL has been found, proceed with the rest of the functions

Please note, that $random$ would really be random, because I don't know, what the value of the var could be.

I'm really not getting forward with this and it would be nice, if anyone could help! :)

Cheers,
J