public static function cleanContent($content)
    {
        $content = self::stripControlCharacters($content);
        // remove Javascript
        $content = preg_replace('@<script[^>]*>.*?<\/script>@msi', '', $content);

        // remove internal CSS styles
        $content = preg_replace('@<style[^>]*>.*?<\/style>@msi', '', $content);

        // prevents concatenated words when stripping tags afterwards
        $content = str_replace(['<', '>'], [' <', '> '], $content);
        $content = static::stripTags($content);

        $content = str_replace(["\t", "\n", "\r", '&nbsp;'], ' ', $content);
        $content = self::stripUnicodeRanges($content);
        $content = preg_replace('/\s{2,}/', ' ', $content);
        $content = trim($content);

        return $content;
    }
public static function cleanContent($content)
    {
        $content = self::stripControlCharacters($content);
        // remove Javascript
        $content = preg_replace('@<script[^>]*>.*?<\/script>@msi', '', $content);

        // remove internal CSS styles
        $content = preg_replace('@<style[^>]*>.*?<\/style>@msi', '', $content);

        // prevents concatenated words when stripping tags afterwards
        $content = str_replace(['<', '>'], [' <', '> '], $content);
        $content = static::stripTags($content);

        $content = str_replace(["\t", "\n", "\r", '&nbsp;'], ' ', $content);
        $content = self::stripUnicodeRanges($content);
        $content = preg_replace('/\s{2,}/', ' ', $content);
        $content = trim($content);

        return $content;
    }
public static function cleanContent ( $ content ) { $ content = self :: stripControlCharacters ( $ content ) ; // remove Javascript $ content = preg_replace ( '@<script[^>]*>.*?<\/script>@msi' , '' , $ content ) ; // remove internal CSS styles $ content = preg_replace ( '@<style[^>]*>.*?<\/style>@msi' , '' , $ content ) ; // prevents concatenated words when stripping tags afterwards $ content = str_replace ( [ '<' , '>' ] , [ ' <' , '> ' ] , $ content ) ; $ content = static :: stripTags ( $ content ) ; $ content = str_replace ( [ "\t" , "\n" , "\r" , '&nbsp;' ] , ' ' , $ content ) ; $ content = self :: stripUnicodeRanges ( $ content ) ; $ content = preg_replace ( '/\s{2,}/' , ' ' , $ content ) ; $ content = trim ( $ content ) ; return $ content ; }
Strips html tags, and tab, new-line, carriage-return, &nbsp; whitespace
characters.

@param string $content String to clean
@return string String cleaned from tags and special whitespace characters
Strips html tags and tab new - line carriage - return &nbsp ; whitespace characters .