As shown below:
$search = Array ("' <script[^>]*?>.*?</script> ' si",//Remove JavaScript
"' <style[^>]*?>.*?) </style> ' Si ', //Remove CSS '
<[/!] *? [^<>]*?> ' Si ', //Remove HTML Tags
"' <!--[/!] *? [^<>]*?> ' Si ',// Remove comment Mark
"' ([RN]) [s]+ '", //Remove white space character
"' & (quot| #34); ' I ", //Replace HTML entity
" ' & (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 "); Run as PHP code
$replace = Array ("",
"", ""
,
"" ",
" \1 ",
" \ "",
"&",
"<" ,
">",
"" ",
chr (161),
Chr (162),
Chr (163),
Chr (169),
" Chr (\1) ");
$document for strings to be processed if the source is a file can $document = file_get_contents ($filename);
$out = Preg_replace ($search, $replace, $document);
You can also use PHP's built-in function strip_tags () to clear html,js, annotations, and so on.
The above is a small series for everyone to bring PHP is to remove all the html,js,css in the Web page, the annotation of the implementation of all the content, I hope that we support cloud-Habitat Community ~