<p>In PHP, replace one URL with another within a string e.g. </p>

<pre><code>New post on the site &lt;a href="http://stackoverflow.com/xyz1"&gt;http://stackoverflow.com/xyz1&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>becomes:</p>

<pre><code>New post on the site &lt;a href="http://yahoo.com/abc1"&gt;http://yahoo.com/abc1&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>Must work for repeating strings as above. Appreciate this is simple but struggling!</p>

Use
str_replace()
:
```
```
$text = str_replace('http://stackoverflow.com/xyz1', 'http://yahoo.com/abc1', $text);
```
```
That will replace the first URL with the second URL in $text.