Tuesday, August 3, 2010

Function to cut html tags from a text, can be used to remove html tags from rss news

Function to cut html tags from a text, can be used to remove html tags from rss news


PHP Code:
function theRealStripTags($string)
{
    
//while there are tags left to remove
    
while(strstr($string'>'))
    {
        
//find position of first carrot
        
$currentBeg strpos($string'<');

        
//find position of end carrot
        
$currentEnd strpos($string'>');

        
//find out if there is string before first carrot
        //if so save it in $tmpstring
        
$tmpStringBeg = @substr($string0$currentBeg);

        
//find out if there is string after last carrot
        //if so save it in $tmpStringEnd
        
$tmpStringEnd = @substr($string$currentEnd 1strlen($string));

        
//cut the tag from the string
        
$string $tmpStringBeg.$tmpStringEnd;
    }

    return 
$string;
}  

No comments:

Post a Comment