-1

So, what i want is to parse normal text to link

but if the text is link then it should not be parsed again

for example: <a href="http://stackoverflow.com">http://stackoverflow.com</a> should not be parsed again to be <a href="http://stackoverflow.com"><a href="http://stackoverflow.com">http://stackoverflow.com</a></a>

That's all

gamehelp16
  • 1,101
  • 1
  • 7
  • 22

2 Answers2

0

One solution is to strip out all the HTML href tags to start off with. Then you have a plain document and you can convert every url to a tag.

Husman
  • 6,819
  • 9
  • 29
  • 47
0
<?php
function TextLink($string)
{
   if($string[0] != "<")
   {
      echo "<a href=\"http://www.".$string."\">".$string."</a>";
   }
}
?>

Call with TextLink('$string');

Dan Wilkins
  • 100
  • 7
  • the text ia a blog post, so the link is inside the other text – gamehelp16 Feb 27 '13 at 08:14
  • I'm confused as to what you want then. You have a blog post like "blah blah blah blah HYPERLINKTHISWORD blah blah blah blah"? Could you maybe give an example as the answer I gave works for your questions example. – Dan Wilkins Feb 27 '13 at 15:29
  • yeah, like that. here is an example: "i have a site, the URL is http://mysite.com, please visit it!" – gamehelp16 Feb 28 '13 at 09:41