public static function convert($html, $options = array()) {

		if ($options === false || $options === true) {
			// Using old style (< 1.0) of passing in options
			$options = array('ignore_errors' => $options);
		}

		$options = array_merge(static::defaultOptions(), $options);

		// check all options are valid
		foreach ($options as $key => $value) {
			if (!in_array($key, array_keys(static::defaultOptions()))) {
				throw new \InvalidArgumentException("Unknown html2text option '$key'");
			}
		}

		$is_office_document = static::isOfficeDocument($html);

		if ($is_office_document) {
			// remove office namespace
			$html = str_replace(array("<o:p>", "</o:p>"), "", $html);
		}

		$html = static::fixNewlines($html);
		if (mb_detect_encoding($html, "UTF-8", true)) {
			$html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");
		}

		$doc = static::getDocument($html, $options['ignore_errors']);

		$output = static::iterateOverNode($doc, null, false, $is_office_document, $options);

		// process output for whitespace/newlines
		$output = static::processWhitespaceNewlines($output);

		return $output;
	}
public static function convert($html, $options = array()) {

		if ($options === false || $options === true) {
			// Using old style (< 1.0) of passing in options
			$options = array('ignore_errors' => $options);
		}

		$options = array_merge(static::defaultOptions(), $options);

		// check all options are valid
		foreach ($options as $key => $value) {
			if (!in_array($key, array_keys(static::defaultOptions()))) {
				throw new \InvalidArgumentException("Unknown html2text option '$key'");
			}
		}

		$is_office_document = static::isOfficeDocument($html);

		if ($is_office_document) {
			// remove office namespace
			$html = str_replace(array("<o:p>", "</o:p>"), "", $html);
		}

		$html = static::fixNewlines($html);
		if (mb_detect_encoding($html, "UTF-8", true)) {
			$html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");
		}

		$doc = static::getDocument($html, $options['ignore_errors']);

		$output = static::iterateOverNode($doc, null, false, $is_office_document, $options);

		// process output for whitespace/newlines
		$output = static::processWhitespaceNewlines($output);

		return $output;
	}
public static function convert ( $ html , $ options = array ( ) ) { if ( $ options === false || $ options === true ) { // Using old style (< 1.0) of passing in options $ options = array ( 'ignore_errors' => $ options ) ; } $ options = array_merge ( static :: defaultOptions ( ) , $ options ) ; // check all options are valid foreach ( $ options as $ key => $ value ) { if ( ! in_array ( $ key , array_keys ( static :: defaultOptions ( ) ) ) ) { throw new \ InvalidArgumentException ( "Unknown html2text option '$key'" ) ; } } $ is_office_document = static :: isOfficeDocument ( $ html ) ; if ( $ is_office_document ) { // remove office namespace $ html = str_replace ( array ( "<o:p>" , "</o:p>" ) , "" , $ html ) ; } $ html = static :: fixNewlines ( $ html ) ; if ( mb_detect_encoding ( $ html , "UTF-8" , true ) ) { $ html = mb_convert_encoding ( $ html , "HTML-ENTITIES" , "UTF-8" ) ; } $ doc = static :: getDocument ( $ html , $ options [ 'ignore_errors' ] ) ; $ output = static :: iterateOverNode ( $ doc , null , false , $ is_office_document , $ options ) ; // process output for whitespace/newlines $ output = static :: processWhitespaceNewlines ( $ output ) ; return $ output ; }
Tries to convert the given HTML into a plain text format - best suited for
e-mail display, etc.

<p>In particular, it tries to maintain the following features:
<ul>
<li>Links are maintained, with the 'href' copied over
<li>Information in the &lt;head&gt; is lost
</ul>

@param string $html the input HTML
@param boolean $ignore_error Ignore xml parsing errors
@return string the HTML converted, as best as possible, to text
@throws Html2TextException if the HTML could not be loaded as a {@link \DOMDocument}
Tries to convert the given HTML into a plain text format - best suited for e - mail display etc .