private function _cleanupText($text = null) { /* -- convert to UTF-8 */ if (function_exists('iconv')) { $text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8//IGNORE", $text); } else { ini_set('mbstring.substitute_character', "none"); $text = mb_convert_encoding($text, 'UTF-8', 'UTF-8'); } /* -- strip HTML tags */ $text = preg_replace('#<[^>]+>#', ' ', $text); /* -- remove excess whitespace */ $text = preg_replace('/\\s{2,}/', ' ', $text); $text = html_entity_decode($text); return $text; }