php regular expression method to remove html: first use "htmlspecialchars_decode" to convert the special HTML entities back to ordinary characters; then use the regular expression "preg_replace('/<\>] >/' ,'',$_str);" can be removed.
Recommended: "PHP Video Tutorial"
php regular removal of html tags
The code is as follows:
$_str = htmlspecialchars_decode($_str); $_str = preg_replace('/<\/?[^>]+>/','',$_str);
htmlspecialchars_decode - Convert special HTML entities back to ordinary characters
preg_replace function performs a regular expression search and replacement.
The above is the detailed content of How to remove html with php regular expression. For more information, please follow other related articles on the PHP Chinese website!