Strip_tags extended function-processing html (for collection)
Strip_tags extended function-processing html (for collection)
/*** This function turns HTML into text * converts html to txt */function html2txt ($ document) {$ search = array ('@
] *?>. *? Script @ Si', // Strip out javascript '@
] *?>. *?@ SiU ', // Strip style tags properly' @ <[\/\!] *? [^ <>] *?> @ Si', // Strip out HTML tags '@
@ ') // Strip multi-line comments including CDATA; $ text = preg_replace ($ search, '', $ document); return $ text ;} /*** removes the HTML tags along with their contents * remove/filter html tags and remove content from tags * Note: $ tags is the opposite when the invert of the label to be retained is true */function strip_tags_content ($ text, $ tags = '', $ invert = FALSE) {preg_match_all ('/<(. + ?) [\ S] * \/? [\ S] *>/Si', trim ($ tags), $ tags); $ tags = array_unique ($ tags [1]); if (is_array ($ tags) and count ($ tags)> 0) {if ($ invert = FALSE) {return preg_replace ('@ <(?! (? : '. Implode (' | ', $ tags).') \ B) (\ w +) \ B. *?>. *?
@ Si', '', $ text);} else {return preg_replace ('@ <('. implode ('|', $ tags ). ') \ B. *?>. *?
@ Si', '', $ text) ;}} elseif ($ invert = FALSE) {return preg_replace ('@ <(\ w +) \ B. *?>. *?
@ Si', '', $ text);} return $ text ;}
The above is the strip_tags extension function-processing html (for collection purposes) content. For more information, please follow the PHP Chinese network (www.php1.cn )!