note 68757 deleted from function.strip-tags by danbrown

From: Date: Tue, 14 Jun 2016 15:06:26 +0000
Subject: note 68757 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-205720@lists.php.net to get a copy of this message
Note Submitter: admin at automapit dot com ---- <?php function html2txt($document){ $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@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; } ?> This function turns HTML into text... strips tags, comments spanning multiple lines including CDATA, and anything else that gets in it's way. It's a frankenstein function I made from bits picked up on my travels through the web, thanks to the many who have unwittingly contributed!

« previous php.notes (#205720) next »