I want to add a referral link to the URL using preg_replace()
<p>I want to add a referral link to all URLs of a post. For example, my referral link is;</p>

<pre><code>http://example.com
</code></pre>

<p>I want to add it <em>after</em> the links in the post.</p>

<p>I'm using the following code right now;</p>

<pre><code>$aff_link = "http://example.com";
$pattern = '/&lt;a(.*)href="([^"]*)"(.*)&gt;/';
$replace = '&lt;a$1href="(.*?)?$att_link"$3&gt;';
$message = preg_replace($pattern, $replace, $message);
</code></pre>

<p>So it Change <a href="http://example.net" rel="nofollow">http://example.net</a> to <a href="http://example.net?http://example.com" rel="nofollow">http://example.net?http://example.com</a></p>

<p>But it is not working as expected. Someone please help.</p>
