note 68749 added to function.strip-tags

From: Date: Wed, 09 Aug 2006 09:08:22 +0000
Subject: note 68749 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-115725@lists.php.net to get a copy of this message
<? 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! ---- Server IP: 66.163.161.117 Probable Submitter: 24.209.159.181 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/68749 Del: integrated -- https://master.php.net/note/delete/68749/integrated Del: useless -- https://master.php.net/note/delete/68749/useless Del: bad code -- https://master.php.net/note/delete/68749/bad+code Del: spam -- https://master.php.net/note/delete/68749/spam Del: non-english -- https://master.php.net/note/delete/68749/non-english Del: in docs -- https://master.php.net/note/delete/68749/in+docs Del: other reasons-- https://master.php.net/note/delete/68749 Reject -- https://master.php.net/note/reject/68749 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115725) next »