Preg_Replace and URLS (HELP!)
I have tried a lot of different things to solve my problem, but I just cant seem to do it. Can anybody help?
I am trying to convert every 'href' found in a page to a bigger version.
<a href="http://www.mywebsite.com/index.php?href=http://www.google.com">MY google link</a>
But the problem is, some people dont have full links.
So when I run it through, it changes to:
<a href="http://www.mywebsite.com/index.php?href=/folder/index.php">MY link</a>
Which obviously doesnt work since I am trying to link to a different domain.
Can anybody help me do what I want?
NOTE: To get the domain address, I can use the variable $src.
You should be able to split an urls with parse_url and fill in missing parts (e.g. domain).