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

How to clear html tags in php

藏色散人
Release: 2023-03-03 15:08:02
Original
2291 people have browsed it

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); 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template