Converting HTML To Plain Text In PHP For E-mail
Answer : Use html2text (example HTML to text), licensed under the Eclipse Public License. It uses PHP's DOM methods to load from HTML, and then iterates over the resulting DOM to extract plain text. Usage: // when installed using the Composer package $text = Html2Text\Html2Text::convert($html); // usage when installed using html2text.php require('html2text.php'); $text = convert_html_to_text($html); Although incomplete, it is open source and contributions are welcome. Issues with other conversion scripts: Since html2text (GPL) is not EPL-compatible. lkessler's link (attribution) is incompatible with most open source licenses. here is another solution: $cleaner_input = strip_tags($text); For other variations of sanitization functions, see: https://github.com/ttodua/useful-php-scripts/blob/master/filter-php-variable-sanitize.php Converting from HTML to text using a DOMDocument is a viable solution. Consider HTML2Text, which requires PHP5: http://www.howtocreate.co.uk/p