note 21304 modified in function.strip-tags by vrana

From: Date: Mon, 22 Dec 2003 16:12:47 +0000
Subject: note 21304 modified in function.strip-tags by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62326@lists.php.net to get a copy of this message
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); ?> --was-- 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); ?> http://www.php.net/manual/en/function.strip-tags.php

« previous php.notes (#62326) next »