PHP intercepts and generates plain text strings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.