Forum Moderators: coopster
I have a need to completely remove links from a large number of text documents. I know that I could simply use the "$strip_tags()" functon. However, I have been asked to remove the entire link, text and all. There are several links per document in random locations throughout each document.
So, how could I remove text from between <a and a> and then remove the leftover <aa>? (Or similar method) Is this even possible?
Any help is greatly appreciated.
while(($begin = strpos($text, "<a"))!== false) {
$end = strpos($text, "</a>", $begin) + 4;//to the end of >
$text = substr($text, 0, $begin) . substr($text, $end, strlen($text) - $end);
}
I'm not sure if you won't have to change $end to +5 or +3. Also to strlen you may need to add or remove 1.
This is a not a very fast method, but will work. Unless someone doesn't write any with ereg_replace then use it.
Best regards
Michal Cibor