PHP removing html tags from string

Try to put it like that

$content = strip_tags($text);

Or you can do it with regular expression like that:

$content = preg_replace('/<[^>]*>/', '', $text);

By this $content = strip_tags($text, '<p>'); you are allowing the <p> tag in the string.

For more info see the link http://php.net/manual/en/function.strip-tags.php

Leave a Comment