title: Prepend to URL PHP
body: <p>I am trying to search through a variable and add a tracking code infront of it. For example this below is saved in database and set to variable <code>$result['block1']</code></p>
  
  <pre><code>&lt;div class="actnbtns"&gt;&lt;a class="btn btn-primary btn-block" href="https://www.landroverusa.com/experiences/lr-experience-drives/index.html"&gt;Land Rover Experience Drives&lt;/a&gt;
  &lt;a class="btn btn-primary btn-block" href="https://www.landroverusa.com/build-your-own/index.html"&gt;BUILD YOUR OWN LAND ROVER&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am wanting to prepend <a href="https://myurl.com/trackingcode?ref=" rel="nofollow noreferrer">https://myurl.com/trackingcode?ref=</a> to all hrefs in the block to track click-throughs. The code would look like below</p>
  
  <pre><code>&lt;div class="actnbtns"&gt;&lt;a class="btn btn-primary btn-block" href="https://myurl.com/trackingcode?ref=https://www.landroverusa.com/experiences/lr-experience-drives/index.html"&gt;Land Rover Experience Drives&lt;/a&gt;
  &lt;a class="btn btn-primary btn-block" href="https://myurl.com/trackingcode?ref=https://www.landroverusa.com/build-your-own/index.html"&gt;BUILD YOUR OWN LAND ROVER&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm just using LandRover as an example, this could be any URL. Thanks for your help in advance.</p>