This article describes PHP empty string html tags Tag: HTML, HTML, HTML Category: html
function clear_html_label ($ html)
{
$ search = array ("'<script [^>] *?>. *? </ script>' si", '' <[/!] *? [^ <>] *?> 'si', ' ([rn]) [s] + '",' '& (quot | # 34);' i ' 'i', '' & gt; # 62; 'i', '' & (nbsp | # 160); 'i' 'i', '' & (copy | # 169); 'i', '' & # (d +); 'e ") ;
$ replace = array ("", "", "1", "", "&", "<", ">", "", chr (161), chr (169), "chr (1)");
return preg_replace ($ search, $ replace, $ html);
}
// Instance application
$ string = 'aaa <br /> <script> fdsafsa';
echo clear_html_label ($ string); // aaa fdsafsa
// Take advantage of the php strip_tags (); www.zzarea.com
echo strip_tags ($ string); // aaa fdsafsa
to sum up,
The results of the above two functions are identical, one is user-defined filter all html function, one is php built-in function, but in effect the php strip_tags () function, it must be much higher. At least why I will not say much.