SOLVED: Answer Below
HOW TO:
– Get all the urls from a file pulled using file_get_contents. The file can by dynamic and have multiple URLs
– Replace all urls with custom A NEW URL and add the existing current url on the end as a Variable
Example:
Change the link http://www.ABC.com to http://www.MyWebsite.com/?link=www.ABC.com
FILE NAME: myHTML.html
The HTML email that will be pulled using file_get_contents
<body>
<p> </p>
<p><a href="http://www.CNN.com" target="_blank">Link One</a></p>
<p><a href="http://www.ABC.com" target="_blank">Link Two</a></p>
<p><a href="http://www.foxnews.com/politics/2013/01/28/us-planning-for-new-drone-base-in-northwest-africa-officials-say/" target="_blank">Link Three</a></p>
<p><a href="ObamaMustSee.com" target="_blank">Link Four</a></p>
</body>
Need to OUTPUT to the following Code:
<body>
<p> </p>
<p><a href="http://www.MyWebsite.com/?link=http://www.CNN.com" target="_blank">Link One</a></p>
<p><a href="http://www.MyWebsite.com/?link=http://www.ABC.com" target="_blank">Link Two</a></p>
<p><a href="http://www.MyWebsite.com/?link=http://www.foxnews.com/politics/2013/01/28/us-planning-for-new-drone-base-in-northwest-africa-officials-say/" target="_blank">Link Three</a></p>
<p><a href="http://www.MyWebsite.com/?link=ObamaMustSee.com" target="_blank">Link Four</a></p>
</body>
Answer that worked for me below!
P.S. +1 If this helped you 🙂
The PHP Code that works
PHP code that calls the file and replaces the links