This article provides a detailed analysis of PHP code for deleting HTMl tags. For more information, see
The code is as follows:
/**
* Retrieve html tags
*
* @ Access public
* @ Param string str
* @ Return string
*
*/
Function deletehtml ($ str ){
$ Str = trim ($ str); // clear spaces on both sides of the string
$ Str = strip_tags ($ str ,"
"); // Clear the html format using the built-in functions of php. Keep P tag
$ Str = preg_replace ("/\ t/", "", $ str); // use a regular expression to match the content to be replaced, such as space, line feed, and will be replaced with null.
$ Str = preg_replace ("/\ r \ n/", "", $ str );
$ Str = preg_replace ("/\ r/", "", $ str );
$ Str = preg_replace ("/\ n/", "", $ str );
$ Str = preg_replace ("//", "", $ str );
$ Str = preg_replace ("//", "", $ str); // matches spaces in html
Return trim ($ str); // return a string
}