You cannot strip a certain list of tags with PHP’s strip_tags() function, you can only strip ‘all but’ tags.

So in order to do so, you’ll need to use regular expressions to do it swiftly:

$strip_list = array('strong', 'p', 'div');
foreach ($strip_list as $tag)
{
    $string = preg_replace('/<\/?' . $tag . '(.|\s)*?>/', '', $html);
}

Job done.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.