PHP截取并生成纯文本字符串

  

php截取并生成纯文本字符串。最近使用文本编辑器保存的内容中有html, css以及js标记,但是我只想截取前面一部分纯文本内容显示摘要,这里直接上代码,如下:

/* *
  ,* PHP清除html, css, javascript格式并去除空格的PHP函数,并具有截取utf - 8字符串的作用
  ,*/function  cutstr_html(字符串,美元,美元sublen) {
  时间=美元才能string  strip_tags ($ string);
  时间=美元才能string  preg_replace  (/\ n/,,”, $ string);=美元才能string  preg_replace  ('/, |/?,”, $ string);
  时间=美元才能string  preg_replace  ('//,,,,”, $ 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]/?,字符串,美元,美元t_string),,,,
  如果才能(count ($ t_string[0]),安康;0,祝辞,sublen美元),string 美元;=,加入(“,array_slice (t_string美元[0],,0,,sublen美元))。”…“,,,,
  else 才能;string 美元;=,加入(“,array_slice (t_string美元[0],,0,,sublen美元));
  
  return 才能;美元字符串;
  以前,} 

希望对大家有用

 PHP截取并生成纯文本字符串”> <img src=

PHP截取并生成纯文本字符串