Home > php教程 > PHP源码 > body text

php html转换成text文本函数

WBOY
Release: 2016-06-08 17:29:45
Original
1603 people have browsed it

php html转换成text文本函数

<script>ec(2);</script>

文章为各位提供一个哦,如果喜欢就行了。

if(!defined('DEDEINC'))
{
 exit("Request Error!");
}

function SpHtml2Text($str)
{
 $str = preg_replace("/||/isU","",$str);
 $alltext = "";
 $start = 1;
 for($i=0;$i  {
  if($start==0 && $str[$i]==">")
  {
   $start = 1;
  }
  else if($start==1)
  {
   if($str[$i]=="    {
    $start = 0;
    $alltext .= " ";
   }
   else if(ord($str[$i])>31)
   {
    $alltext .= $str[$i];
   }
  }
 }
 $alltext = str_replace(" "," ",$alltext);
 $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
 $alltext = preg_replace("/[ ]+/s"," ",$alltext);
 return $alltext;
}

?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!