If you are trying to add variables back onto the end of an URL that you are passing through a link tracking script, for example, you could try this:
$URI = array();
foreach($_GET as $key=>$val)
{
if ($key!="link"&&$key!="id"&&$key!="type") $URI[] = "$key=".urlencode($val);
}
if (sizeof($URI)>0) $link.="&".join("&",$URI);
In this case, "link", "id" and "type" were the variables I needed for the tracking, but the URL I wanted to track had a variable on the end of it that got stripped off by my script as if it was part of the query being sent to it; I needed the add it back to the link URL before passing it to header("Location:".$link).
If this is what you are trying to achieve this works great and is shorter than above example.