Home > Backend Development > PHP Tutorial > Simple filtering of HTML tags in string_PHP tutorial

Simple filtering of HTML tags in string_PHP tutorial

WBOY
Release: 2016-07-21 15:58:44
Original
841 people have browsed it

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

for( $i=0; $i<$l; $i++ )
{
if( substr( $scr, $i, 1 ) == "<" )
{
// Current location
$ii = $i;

// Stop looping when $i is greater than the character length
while( substr( $scr, $i, 1 ) != ">" && $i < $l )
$i++;

// When reaching the end of the large string, reset $i to the starting position of '<' found
if ( $i == $l )
{
$i = $ii - 1;
// Indicates reaching the end of the string
$b = 1;
}

$i++;
}


// Only accept characters when the next character is not '<', otherwise $i--, start searching from this '<'
if ( substr( $scr, $i, 1 ) != '<' || $b == 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 ) == "" ) { // Current position $ii = $i; // Stop looping when $i is greater than the character length...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template