Answers for "Strip HTML From Text"

0

Strip HTML From Text

const stripHtml = html => (new DOMParser().parseFromString(html, 'text/html')).body.textContent || ''
Posted by: Guest on April-14-2022
0

Strip off tags in text

<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";

// Allow <p> and <a>
echo strip_tags($text, '<p><a>');

// as of PHP 7.4.0 the line above can be written as:
// echo strip_tags($text, ['p', 'a']);
?>
Posted by: Guest on June-25-2021

Browse Popular Code Answers by Language