Forum Moderators: coopster
Right now I'm using preg_replace to modify URLS to properly display. What is causing me grief is that I have multiple GET variables in play.
Imagine my URL is this :
.../?show=50&order=ASC
My program will be able to take that current URL and change one variable to something else without modifying the other variables.
ie.
.../?show=100&order=ASC
Right now I can successfully modify the inside variable, but cannot change the last one.
My regex statement is this:
preg_replace('/' . $var . '=([^&]+)[&]/', $result, $URL);'
where $var is the variable I'm changing, $result is the proper URL, and $URL is the input string. As you can imagine, it replaces properly on the inside because the code reaches the & character, but not when it's the last one.
What can I add to make it stop at the & or at the end of line?
'/' . $var . '=([^&]+)/'
Also, can't you just use a simple str_replace here? I don't see why you are using regex.