PHP methods to clear all useless tags in strings, php strings. PHP clears all useless tags in a string. This document describes how php clears all useless tags in a string. Share it with you for your reference. PHP to clear all useless tags in strings.
This example describes how to clear all useless tags in a string in PHP. Share it with you for your reference. The specific implementation method is as follows:
Many times, you need to output some "pure" strings, that is, to remove any impurities, such as Html tags, spaces, and other text. this is the output abstract, the following function can help you implement one point.
The PHP instance code is as follows:
The code is as follows:
Function Bing_string_cleanr ($ string ){
$ String = trim ($ string );
$ String = strip_tags ($ string );
$ String = htmlspecialchars ($ string, ENT_QUOTES, 'utf-8 ');
$ String = str_replace ("n", "", $ string );
$ String = trim ($ string );
Return $ string;
}
The usage is as follows:
The code is as follows:
Echo Bing_string_cleanr ('internal capacity
Asdfeiuonsdfje ');
Php deletes the blank space. the code is as follows:
The code is as follows:
<? Php
$ Str = "This line containstliberal rn use of whitespace. nn ";
// First remove the leading/trailing whitespace
// Remove the start and end spaces.
$ Str = trim ($ str );
// Now remove any doubled-up whitespace
// Remove the blank space crowded with other items
$ Str = preg_replace ('/s (? = S)/', '', $ str );
// Finally, replace any non-space whitespace, with a space
// Finally, remove the non-space blank and replace it with a space.
$ Str = preg_replace ('/[nrt]/', '', $ str );
// Echo out: 'This line contains liberal use of whitespace .'
Echo"
{$str}
";
?>
I hope this article will help you with PHP programming.
Examples in this article describes how PHP clears all useless tags in strings. Share it with you for your reference. Implementation...