replace link with another
<p>I'm struggling on replacing text in each link. </p>

<pre><code>$reg_ex = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

$text = '&lt;br /&gt;&lt;p&gt;this is a content with a link we are supposed to &lt;a href="http://www.google.com"&gt;click&lt;/a&gt;&lt;/p&gt;&lt;p&gt;another - this is a content with a link we are supposed to &lt;a href="http://www.amazon.com"&gt;click&lt;/a&gt;&lt;/p&gt;&lt;p&gt;another - this is a content with a link we are supposed to &lt;a href="http://www.wow.com"&gt;click&lt;/a&gt;&lt;/p&gt;';

if(preg_match_all($reg_ex, $text, $urls))
{

    foreach($urls[0] as $url)
    {

        echo $replace = str_replace($url,'http://www.sometext'.$url,  $text);
    }

}
</code></pre>

<p>From this I'm getting 3x the same text and links are changed one by one: everytime is replaced only one link - because I use foreach, I know. 
But I don't know how to replace them all at once.
Your help would be great!</p>
