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.
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!