This article describes the HTML tags in a PHP empty string
There are two ways to filter all the HTML tags in a string one is we write a function ourselves, with regular filter, one is to use PHP with the function Strip_tags Oh.
Copy Code code as follows:
function Clear_html_label ($html)
{
$search = Array ("' <script[^>]*?>.*?</script> ' si", "' <[/!] *? [^<>]*?> ' Si "," ' ([RN]) [s]+ ' "," ' & (quot| #34); ' I "," ' & (amp| #38); ' I "," ' & (lt| #60); ' I "," ' & (gt| #62); ' I "," ' & (nbsp| #160); ' I "," ' & (iexcl| #161); ' I "," ' & (cent| #162); ' I "," ' & (pound| #163); ' I "," ' & (copy| #169); ' I "," ' &# (d+); ' E ");
$replace = Array ("", "", "1", "" "," & "," < "," > "," ", Chr (161), Chr (162), Chr (163), Chr (169)," Chr (1) ");
Return Preg_replace ($search, $replace, $html);
}
Instance Application
$string = ' aaa<br/> <SCRIPT>FDSAFSA ';
echo Clear_html_label ($string);//aaa FDSAFSA
Using PHP with its own function strip_tags (); Www.zzarea.com
echo Strip_tags ($string);//aaa FDSAFSA
Summarize
The results of the above two functions are identical, one is user-defined filter all HTML functions, one is PHP built-in function, but on the green, PHP's Strip_tags () function, certainly much higher. At least why I don't say much.