protected function stripHtml($html)
    {
        $str = html_entity_decode($html);

        // Strip HTML (Replace br with newline, remove "invisible" tags and strip other tags)
        $str = preg_replace('#<br[^>]*?>#siu', "\n", $str);
        $str = preg_replace(
            [
                '#<applet[^>]*?.*?</applet>#siu',
                '#<embed[^>]*?.*?</embed>#siu',
                '#<head[^>]*?>.*?</head>#siu',
                '#<noframes[^>]*?.*?</noframes>#siu',
                '#<noscript[^>]*?.*?</noscript>#siu',
                '#<noembed[^>]*?.*?</noembed>#siu',
                '#<object[^>]*?.*?</object>#siu',
                '#<script[^>]*?.*?</script>#siu',
                '#<style[^>]*?>.*?</style>#siu'
            ],
            '',
            $str
        );
        $str = strip_tags($str);

        // Trim whitespace
        $str = str_replace("\t", '', $str);
        $str = preg_replace('#\n\r|\r\n#', "\n", $str);
        $str = preg_replace('#\n{3,}#', "\n\n", $str);
        $str = preg_replace('/ {2,}/', ' ', $str);
        $str = implode("\n", array_map('trim', explode("\n", $str)));
        $str = trim($str)."\n";
        return $str;
    }
protected function stripHtml($html)
    {
        $str = html_entity_decode($html);

        // Strip HTML (Replace br with newline, remove "invisible" tags and strip other tags)
        $str = preg_replace('#<br[^>]*?>#siu', "\n", $str);
        $str = preg_replace(
            [
                '#<applet[^>]*?.*?</applet>#siu',
                '#<embed[^>]*?.*?</embed>#siu',
                '#<head[^>]*?>.*?</head>#siu',
                '#<noframes[^>]*?.*?</noframes>#siu',
                '#<noscript[^>]*?.*?</noscript>#siu',
                '#<noembed[^>]*?.*?</noembed>#siu',
                '#<object[^>]*?.*?</object>#siu',
                '#<script[^>]*?.*?</script>#siu',
                '#<style[^>]*?>.*?</style>#siu'
            ],
            '',
            $str
        );
        $str = strip_tags($str);

        // Trim whitespace
        $str = str_replace("\t", '', $str);
        $str = preg_replace('#\n\r|\r\n#', "\n", $str);
        $str = preg_replace('#\n{3,}#', "\n\n", $str);
        $str = preg_replace('/ {2,}/', ' ', $str);
        $str = implode("\n", array_map('trim', explode("\n", $str)));
        $str = trim($str)."\n";
        return $str;
    }
protected function stripHtml ( $ html ) { $ str = html_entity_decode ( $ html ) ; // Strip HTML (Replace br with newline, remove "invisible" tags and strip other tags) $ str = preg_replace ( '#<br[^>]*?>#siu' , "\n" , $ str ) ; $ str = preg_replace ( [ '#<applet[^>]*?.*?</applet>#siu' , '#<embed[^>]*?.*?</embed>#siu' , '#<head[^>]*?>.*?</head>#siu' , '#<noframes[^>]*?.*?</noframes>#siu' , '#<noscript[^>]*?.*?</noscript>#siu' , '#<noembed[^>]*?.*?</noembed>#siu' , '#<object[^>]*?.*?</object>#siu' , '#<script[^>]*?.*?</script>#siu' , '#<style[^>]*?>.*?</style>#siu' ] , '' , $ str ) ; $ str = strip_tags ( $ str ) ; // Trim whitespace $ str = str_replace ( "\t" , '' , $ str ) ; $ str = preg_replace ( '#\n\r|\r\n#' , "\n" , $ str ) ; $ str = preg_replace ( '#\n{3,}#' , "\n\n" , $ str ) ; $ str = preg_replace ( '/ {2,}/' , ' ' , $ str ) ; $ str = implode ( "\n" , array_map ( 'trim' , explode ( "\n" , $ str ) ) ) ; $ str = trim ( $ str ) . "\n" ; return $ str ; }
Convert an HTML string to plain-text.

@param string $html The HTML string to convert.
@return string The resulting plain-text string.
Convert an HTML string to plain - text .