Re: Something like strip_tags?
| From: | Anguz | Date: | Tue, 06 Jul 2004 00:41:54 +0000 |
| Subject: | Re: Something like strip_tags? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189757@lists.php.net to get a copy of this message | ||
Jason Paschal wrote:
i'd like to be able to strip only one type of HTML tag from a web document (<a>), but to do that with strip_tags(), i'd have to predict every possible HTML tag that might be used, except for the one i want to strip, and put those in the allowable tags parameter. That's why I was hoping someone knew of a better way to accomplish this. Any suggestions are welcome. Thanks in advance, ~jI'd probably do this: $str = preg_replace('~<a.+?</a>~is', '', $str); If you wanted to keep the anchored text and URLs, then something like: $str = preg_replace('~<a href="(.+?)".*?>(.+?)</a>~is', '$2 [$1]', $str); HIH, Cristian