国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 line
673B

  1. <?php
  2. if(!defined('DEDEINC'))
  3. {
  4. exit("Request Error!");
  5. }
  6. function SpHtml2Text($str)
  7. {
  8. $str = preg_replace("/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU","",$str);
  9. $alltext = "";
  10. $start = 1;
  11. for($i=0;$i<strlen($str);$i++)
  12. {
  13. if($start==0 && $str[$i]==">")
  14. {
  15. $start = 1;
  16. }
  17. else if($start==1)
  18. {
  19. if($str[$i]=="<")
  20. {
  21. $start = 0;
  22. $alltext .= " ";
  23. }
  24. else if(ord($str[$i])>31)
  25. {
  26. $alltext .= $str[$i];
  27. }
  28. }
  29. }
  30. $alltext = str_replace(" "," ",$alltext);
  31. $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
  32. $alltext = preg_replace("/[ ]+/s"," ",$alltext);
  33. return $alltext;
  34. }
  35. ?>