Trouble editing a link with str_replace
<p>Ideally I want to use the php script as an include that will be on every page. </p>

<p>I have link: <a href="http://www.facebook.com/sharer.php?u=http://123.456.789.101/~user/file.php" rel="nofollow">http://www.facebook.com/sharer.php?u=http://123.456.789.101/~user/file.php</a></p>

<p>and I want to make it look like this: <a href="http://www.facebook.com/sharer.php?u=http://MyUrl.com/file.php" rel="nofollow">http://www.facebook.com/sharer.php?u=http://MyUrl.com/file.php</a></p>

<p>Essentially I want to replace "123.456.789.101/~user" with "MyUrl.com"</p>

<p>There will be multiple links that I am going to need to change. Also, the file name "file.php" part changes for each page. I will not know what the exact page name will be. </p>

<p>I tried this but it does not work. If I echo the str_replace it gives me the correct link but I can not get the new link to replace the old link in the page.</p>

<pre><code>&lt;?php
$string = 'http://www.facebook.com/sharer.php?u=http://123.456.789.101/~user';
$pattern = '123.456.789.101/~user';
$replacement = 'MyUrl.com';
str_replace($pattern, $replacement, $string);
?&gt;
</code></pre>

<p>Thank you so much.</p>
