I am trying to remove all content between hyperlink tags. For example, if I start with this: I would like <a href="http://www.google.com">to remove</a> this link. Code (markup): I would like the result to be: I would like this link. Code (markup): I am trying to find all instances of <a> and </a> and remove everything between it using PHP... Any help on this??? Im thinking something using preg_replace?
Theres loads of ways to do it, it depends if your using other tags and so forth; rather quickly; <?php $str = 'I would like <a href="http://www.google.com">to remove</a> this link.'; $filter = preg_replace("/<a(.*)<\/a>/iUs", "", $str); print $filter; ?> PHP: OUTPUT: I would like this link.
Yes, regex would be the best. And for the record, don't send people PMs of the answer. People may need to find the answer later via search.