PHP: Replace 1st char in a string - to create a link to itself
<p>in my test.php I would like to provide a link back to the production script index.php, passing the same GET-parameters. So I'm trying this PHP-code:</p>

<pre><code>foreach ($_GET as $key =&gt; $val) {
        $get .= "&amp;$key=$val";
}
# this one is wrong - I want to replace just the first "&amp;"
$get = str_replace("&amp;", "?", $get);

echo '&lt;p&gt;You are viewing the test version.&lt;/p&gt;

&lt;p&gt;&lt;a href="/index.php' . $get .
'"&gt;Return to production version&lt;/a&gt;&lt;/p&gt;';
</code></pre>

<p>How do I replace just the 1st char in the $get string?</p>

<p>Or maybe there is a nicer way to create a "self-link"?</p>

<p>Thank you,
Alex</p>
