(PHP 5 >= 5.4)
strip_html
— Strip HTML and PHP tags from a string.
string strip_html( string $str )
This function tries to return a string with all NULL bytes, HTML and PHP tags stripped from a given str
. Unlike strip_tags()
, this function is mindful of line-breaks and metadata elements (e.g., <style>
).
This function is useful for converting a HTML-rich string into a plain-text string for emails.
str
— The input string.
Returns the stripped string.
$ composer require mcaskill/php-strip-html
Why are you not using composer? Download Function.Strip-HTML.php
from the gist and save the file into your project path somewhere.
Very nice piece of code. For me, this was an improvement! What do you think?