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

小云云
Release: 2023-03-21 16:06:01
Original
30087 people have browsed it


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

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!

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