/ Published in: PHP

Turn a html source into a full text document by removing all html tags and other unneeded code.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function html2txt($document){ '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<[?]php[^>].*?[?]>@si', //scripts php '@<[?][^>].*?[?]>@si', //scripts php '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA return $text; } // Usage $txt = html2txt($html_source);
URL: http://www.phpsnippets.info/convert-html-source-to-full-text
Comments
