title: PHP: preg_match search and replace href
body: <p>i have html and contain many links like this:</p>
  
  <pre><code>&lt;a href="http://www.mydomain1.com"&gt;Click Me&lt;/a&gt;
  </code></pre>
  
  <p>i would like to:</p>
  
  <p>copy its original link: <strong><a href="http://www.mydomain1.com" rel="nofollow">http://www.mydomain1.com</a></strong></p>
  
  <p>append text infront it: <strong>test.php?url=<a href="http://www.mydomain1.com" rel="nofollow">http://www.mydomain1.com</a></strong></p>
  
  <p>so that the final output for all href to become:</p>
  
  <pre><code>&lt;a href="test.php?url=http://www.mydomain1.com"&gt;Click Me&lt;/a&gt;
  </code></pre>
  
  <p>how to do this?</p>