Php filters string functions. Share a php string filter function with the following code: functionStripHTML ($ string) {$ patternarray (script [^] *?. *? Scriptsi, style [^] *?. *? Stylesi, [!] *? [^] *? Si shares a php string filter function with the following code:
function StripHTML($string){$pattern=array ("'
]*?>.*?《script》'si", "'
]*?>.*?'si", "'<[\/\!]*?[^<>]*?>'si", "'([\r\n])[\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 ($pattern, $replace, $str);}
Articles you may be interested in
- Some powerful string processing functions forgotten by php
- Php's most precise string length truncation function
- Php string replacement function str_replace is faster than preg_replace
- Summary of String Functions in PHP
- PHP string escape functions (addslashes, stripslashes)
- Js array to string, js string to array method summary
- Php extracts numbers from strings
- PHP generates continuous numbers (letters) array function range () analysis, PHP lottery program function
Using function StripHTML ($ string) {$ pattern = array ("'script [^] *?. *? /Script 'Si "," 'style [^] *?. *? /Style 'Si "," '[\/\!] *? [^] *? 'Si "...