]+>/','', $_str);" can be removed."/> ]+>/','', $_str);" can be removed.">

Home  >  Article  >  Backend Development  >  How to remove html with php regular expression

How to remove html with php regular expression

藏色散人
藏色散人Original
2020-08-31 09:54:582752browse

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('/5e77056087f18f3abd310ca37b0b1899] >/' ,'',$_str);" can be removed.

How to remove html with php regular expression

Recommended: "PHP Video Tutorial"

php regular removal of html tags

The code is as follows:

$_str = htmlspecialchars_decode($_str);             
 
$_str = preg_replace(&#39;/<\/?[^>]+>/&#39;,&#39;&#39;,$_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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn