Home  >  Article  >  Backend Development  >  json string simple filter HTML tags in string

json string simple filter HTML tags in string

WBOY
WBOYOriginal
2016-07-29 08:35:501250browse

function 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
while( substr( $scr, $i, 1 ) ! = ">" && $i < $l )
$i++;

// When reaching the end of the large string, reset $i to the starting position of '<' if ( $i == $ l )
                                                                                                                                                                         . Accept characters, otherwise $i--, start searching from this '<' if ( substr( $scr, $i, 1 ) != '<' || $b == 1 )
$str = $ str . substr( $scr, $i, 1 );
else
$i--;
}

return( $str );

}

The above introduces the json string and simply filters the HTML tags in the string, including the content of the json string. I hope it will be helpful to friends who are interested in PHP tutorials.



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