PHP: Replace 1st char in a string - to create a link to itself

descaro

New Member
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:\[code\]foreach ($_GET as $key => $val) { $get .= "&$key=$val";}# this one is wrong - I want to replace just the first "&"$get = str_replace("&", "?", $get);echo '<p>You are viewing the test version.</p><p><a href="http://stackoverflow.com/index.php' . $get .'">Return to production version</a></p>';\[/code\]How do I replace just the 1st char in the $get string?Or maybe there is a nicer way to create a "self-link"?Thank you,Alex
 
Back
Top