public static function normalise($html)
    {
        $rules = array(
            '#<!--.*?-->#si',
            '#<(script|option|textarea)[^>]*>.*?</\1>#si',
            '#<img[^>]*alt\s*=\s*("([^"]*)"|\'([^\']*)\'|([a-zA-Z_]+))[^>]*>#',
            '#<[^>]*>#',
        );

        $replace = array(
            '',
            '',
            ' \2\3\4 ',
            '',
        );

        $text = preg_replace($rules, $replace, $html);
        $text = html_entity_decode($text, ENT_QUOTES);
        $text = preg_replace('#\s+#', ' ', $text);

        return trim(trim($text), "\xA0");        // @todo The \xAO is a &nbsp;. Add a test for this.
    }
public static function normalise($html)
    {
        $rules = array(
            '#<!--.*?-->#si',
            '#<(script|option|textarea)[^>]*>.*?</\1>#si',
            '#<img[^>]*alt\s*=\s*("([^"]*)"|\'([^\']*)\'|([a-zA-Z_]+))[^>]*>#',
            '#<[^>]*>#',
        );

        $replace = array(
            '',
            '',
            ' \2\3\4 ',
            '',
        );

        $text = preg_replace($rules, $replace, $html);
        $text = html_entity_decode($text, ENT_QUOTES);
        $text = preg_replace('#\s+#', ' ', $text);

        return trim(trim($text), "\xA0");        // @todo The \xAO is a &nbsp;. Add a test for this.
    }
public static function normalise ( $ html ) { $ rules = array ( '#<!--.*?-->#si' , '#<(script|option|textarea)[^>]*>.*?</\1>#si' , '#<img[^>]*alt\s*=\s*("([^"]*)"|\'([^\']*)\'|([a-zA-Z_]+))[^>]*>#' , '#<[^>]*>#' , ) ; $ replace = array ( '' , '' , ' \2\3\4 ' , '' , ) ; $ text = preg_replace ( $ rules , $ replace , $ html ) ; $ text = html_entity_decode ( $ text , ENT_QUOTES ) ; $ text = preg_replace ( '#\s+#' , ' ' , $ text ) ; return trim ( trim ( $ text ) , "\xA0" ) ; // @todo The \xAO is a &nbsp;. Add a test for this. }
Turns HTML into text browser visible text.
Images are converted to their alt text and tags are supressed.
Entities are converted to their visible representation.

@param string $html        HTML to convert.

@return string             Plain text.
Turns HTML into text browser visible text . Images are converted to their alt text and tags are supressed . Entities are converted to their visible representation .