Home >Backend Development >PHP Problem >How to clear html tags in php

How to clear html tags in php

藏色散人
藏色散人Original
2020-07-31 09:13:592321browse

php method to clear html tags: first create a PHP code sample file; then define a "cutstr_html" method; finally pass "preg_replace(["\t", "\r\n", "\r ", "\n", " "]); " method can clear the html tag.

How to clear html tags in php

Recommended: "PHP Video Tutorial"

php clear html tag

The code is as follows:

function cutstr_html($string){  

    $string = strip_tags($string);  

   $string = preg_replace(["\t", "\r\n", "\r", "\n", " "], [], $string); 

   return trim($string); 
}

The above is the detailed content of How to clear html tags in php. 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