note 21304 deleted from function.strip-tags by ezyang
| From: | ezyang@php.net | Date: | Tue, 05 Aug 2008 16:19:28 +0000 |
| Subject: | note 21304 deleted from function.strip-tags by ezyang | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143168@lists.php.net to get a copy of this message | ||
Note Submitter: mrmaxxx333 at triad dot rr dot com
----
to rid everything in between script tags, including the script tags, i use this.
<?php
$description = ereg_replace("~<script[^>]*>.+</script[^>]*>~isU",
"", $description);
?>
it hasn't been extensively tested, but it works.
also, i ran into trouble with a href tags. i wanted to strip out the url in them. i did this to turn
an <a href="blah.com">welcome to blah</a> into welcome to blah (blah.com)
<?php
$string =
preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is',
'\2 (\1)', $string);
?>