replace link in text

Gateway Lx6810-01 desktop
January 21, 2010 at 13:25:09
Specs: Windows XP, pentium 4
Hey guys, I need to create a function that takes a string and removes all links from it. For instance

string="I love"

I want to remove the whole link starting with <a and stopping after a>.

Also if they out in http I would need it to take that into account. I think I need to use regular expressions but am not at that level yet.

See More: replace link in text

Report •

January 21, 2010 at 22:58:49

   $htm = "<a href=''>test1</a><br />" .
          "<a href=''>test2</a><br />" .
          "<a href=''>test3</a><br />" .
          "<a href=''>test4</a><br />" .
          "<a href=''>test5</a><br />";

   echo $htm . "<br />";
   echo stripTheTag($htm); 

function stripTheTag($link) {

   return (preg_replace('@<[\/\!]*?[^<>]*?>@si', ' ', $link));



Report •

January 22, 2010 at 10:33:31
I tried it out it works great so far. I need to really learn regular expressions. Any chance you could decipher what you write into readable terms fo I can see what the characters meant and did. Either way thanks.

Report •

January 30, 2010 at 02:48:37
Thanks for is best of me..buddy!!!

Report •
Related Solutions

Ask Question