PHP intercepts and generates a plain text string. Recently saved with the text editor has html,css and JS tags, but I just want to intercept the previous part of the plain text content display summary, here directly on the code, as follows:
/** * php PHP functions that clear HTML, CSS, JS formats, and remove spaces, and have the function of intercepting UTF-8 strings */function cutstr_html ($string, $sublen) { $string = strip_tags ($string); $string = preg_replace ('/\n/is ', ', $string); $string = preg_replace ('/ |/is ', ', $string); $string = preg_replace ('/ /is ', ', $ string); preg_match_all ("/[\x01-\x7f]|[ \xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]| [\xe1-\xef] [\X80-\XBF] [\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]| [\xf1-\xf7] [\X80-\XBF] [\X80-\XBF] [\x80-\xbf]/", $string, $t _string); if (count ($t _string[0]) - 0 > $sublen) $string = join (", array_slice ($t _string[0], 0, $ Sublen)). " ... "; else $string = join (', array_slice ($t _string[0], 0, $sublen)); return $string; }
Hope to be useful to everyone
650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0026.gif "alt=" J_0026.gif "/>650" this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0018.gif "alt=" J_0018.gif "/>
This article is from the "Gaovan" blog, make sure to keep this source http://gaowanyao.blog.51cto.com/11272977/1946484
PHP intercepts and generates plain text strings