strip_tags

$inputString = '<p>This is a <script>alert("Sensitive information");</script> paragraph.</p>';
$allowedTags = '<p><a><strong>'; // Specify the tags you want to allow

$cleanedString = strip_tags($inputString, $allowedTags);