Home  >  Article  >  Backend Development  >  简单的过滤字符串中的HTML标记_PHP教程

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

WBOY
WBOYOriginal
2016-07-21 15:58:44707browse

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 );
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/317540.htmlTechArticlefunction deleteHtml( $scr ) { $l = strlen( $scr ); for( $i=0; $i$l; $i++ ) { if( substr( $scr, $i, 1 ) == "" ) { // 当前位置 $ii = $i; // 当$i大于字符长度时停止循环...
Statement:
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