<?
// =======================
// helper function to strip out html tags
// =======================
public function html2txt($document)
{
  $search = array('#<script[^>]*?>.*?</script>#si',  // Strip out js
		   '#<[\/\!]*?[^<>]*?>#si',          // Strip out HTML tags
		   '#<style[^>]*?>.*?</style>#siU',  // Strip style tags properly
		   '#<![\s\S]*?--[ \t\n\r]*>#'       // Strip multi-line comments including CDATA
	);
	
   $text = preg_replace($search, '', $document);
   return $text;
}