Home >Backend Development >PHP Tutorial >How to remove all tags, spaces and whitespace from Html with PHP

How to remove all tags, spaces and whitespace from Html with PHP

小云云
小云云Original
2018-03-16 15:26:3930078browse


This article shares a small piece of code with you. It mainly shares with you how to remove all tags, spaces and blanks in Html with PHP. I hope it can help you.

function cutstr_html($string, $sublen){  
    $string = strip_tags($string);  
    $string = trim($string);  
    $string = ereg_replace("\t","",$string);  
    $string = ereg_replace("\r\n","",$string);  
    $string = ereg_replace("\r","",$string);  
    $string = ereg_replace("\n","",$string);  
    $string = ereg_replace(" ","",$string);  
    return trim($string);  
}

Related recommendations:

Solution to the problem that there is still a blank space after using strip_tags() to remove html tags in php

php removes html tags Function - strip_tags and htmlspecialchars

php removes html tag code

The above is the detailed content of How to remove all tags, spaces and whitespace from Html with 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