Home > php教程 > php手册 > 简单的过滤字符串中的HTML标记

简单的过滤字符串中的HTML标记

WBOY
Release: 2016-06-13 12:34:44
Original
918 people have browsed it

function deleteHtml( $scr )
{
 $l = strlen( $scr );

 for( $i=0; $i {
  if( substr( $scr, $i, 1 ) == "  {
   // 当前位置
   $ii = $i;

   // 当$i大于字符长度时停止循环
   while( substr( $scr, $i, 1 ) != ">" && $i     $i++;

   // 当到大字符串最后时,重置$i到找到'   if ( $i == $l )
   {
    $i = $ii - 1;
    // 表示到达字符串结尾
    $b = 1;
   }

   $i++;
  }

  
  // 当下一个字符不是'  if (  substr( $scr, $i, 1 ) != '   $str = $str . substr( $scr, $i, 1 );
  else
   $i--;
 }

 return( $str );
}

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