You forgot to increment $count on each iteration, so it remains at 0, hence $count == 0 never evaluates to false.
$count = true;
$posted = '';
foreach ($_GET as $key => $value)
{
if ($count)
{
$posted = "?" . $key . "=" . $value;
$count = false;
}
else
{
$posted .= "+" . $key . "=" . $value;
}
}
$_SESSION['posted'] = $posted;
Finally, take a look into $_SERVER['QUERY_STRING'], which probably gives you the value you want immediately, assuming that your server uses '+' as the argument separator.