To eminate the script tags found in html, don't use the preg_replace approach. The .* can include </script> when there are multiple script tags, and you could be replacing content other than the script tag.

The following function will find the begining and ending character occurance on the script tag, crop the html, then repeat the process until all tags are removed.

function strip_tag_script($html) {
$pos1 = false;
$pos2 = false;
do {
if ($pos1 !== false && $pos2 !== false) {
$first = NULL;
$second = NULL;
if ($pos1 > 0)
$first = substr($html, 0, $pos1);
if ($pos2 < strlen($html) - 1)
$second = substr($html, $pos2);
$html = $first . $second;
}
preg_match("/<script[^>]*>/i", $html, $matches);
$str1 =& $matches[0];
preg_match("/<\/script>/i", $html, $matches);
$str2 =& $matches[0];
$pos1 = strpos($html, $str1);
$pos2 = strpos($html, $str2);
if ($pos2 !== false)
$pos2 += strlen($str2);
} while ($pos1 !== false && $pos2 !== false);
return $html;
}

--was--
To eminate the script tags found in html, don't use the preg_replace approach. The .* can include </script> when there are multiple script tags, and you could be replacing content other than the script tag.

The following function will find the begining and ending character occurance on the script tag, crop the html, then repeat the process until all tags are removed.

function strip_tag_script($html) {
$pos1 = false;
$pos2 = false;
do {
if ($pos1 !== false && $pos2 !== false) {
$first = NULL;
$second = NULL;
if ($pos1 > 0)
$first = substr($html, 0, $pos1);
if ($pos2 < strlen($html) - 1)
$second = substr($html, $pos2 + 1);
$html = $first . $second;
}
preg_match("/<script[^>]*>/i", $html, $matches);
$str1 =& $matches[0];
preg_match("/<\/script>/i", $html, $matches);
$str2 =& $matches[0];
$pos1 = strpos($html, $str1);
$pos2 = strpos($html, $str2);
if ($pos2 !== false)
$pos2 += strlen($str2);
} while ($pos1 !== false && $pos2 !== false);
return $html;
}

[url]http://www.php.net/manual/en/function.strip-tags.php[/url]