The page: /index.php?page=6&test=1&test2=2
The code below strip's page=6 off of this so I can add our new page to the url and add the $url_without_page_var back to our link again:
$_SERVER['argv'][0]
// Displays: page=6&test=1&test2=2
And
$url_without_page_var=preg_replace('/page=(\d+)/i','',$_SERVER['argv'][0]);
// Displays: &test=1&test2=2
Ok so that code lets me take the page=6 off of page=6&test=1&test2=2 I can then change the page number and add this all back together.
My problem is often the page in the URL will not always be in the same position, it may not be the 1st or last items And this is what will happen when, see how the URL is incorrect now;
/page.php?&test=1&test2=2 ERROR-HERE-ALSO page=9