Simplest way to convert all html links in a string using PHP
- by Gaz
I am trying to convert a block of text that contains html text - i'd like to find all http links and convert them for link tracking purposes.
So eg anything like this in a string would be converted to the latter
<a href="http://www.google.com">Some Link</a>
<a href="http://www.mysite.com/tracking.php?url=www.google.com">Some Link</a>
Can anyone how to do this taking into account the original string will consists of all sorts of html, images etc..