This question already has an answer here:
I have a string like this:
$mystring = "some words1 some more words2 <script>some variable inside</script> some more words3";
I want to remove script tags and inside it. I want to have "some words1 some more words2 some more words3" How can I remove that part
</div>
Try this solution
$srting = 'some words1 some more words2 <script>some variable inside</script> some more words3';
echo strip_tags_content($srting);
function strip_tags_content($text) {
return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);
}
// Only For script tags
preg_replace('(<script>(.*?)</script>)', '', $text);
// output :some words1 some more words2 some more words3