note 71962 added to function.strip-tags

From: Date: Tue, 26 Dec 2006 13:18:45 +0000
Subject: note 71962 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-120925@lists.php.net to get a copy of this message
admin at automapit dot com's function is great. Cleans everything I don't need :). But there is a small problem; strip style tags line should be before strip html tags line. Otherwise, strip html tags section cleans the <style></style> and between them is stays there as text. <?php function html2txt($document){ $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA ); $text = preg_replace($search, '', $document); return $text; } ?> ---- Server IP: 85.111.4.6 Probable Submitter: 195.214.135.160 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/71962 Del: integrated -- https://master.php.net/note/delete/71962/integrated Del: useless -- https://master.php.net/note/delete/71962/useless Del: bad code -- https://master.php.net/note/delete/71962/bad+code Del: spam -- https://master.php.net/note/delete/71962/spam Del: non-english -- https://master.php.net/note/delete/71962/non-english Del: in docs -- https://master.php.net/note/delete/71962/in+docs Del: other reasons-- https://master.php.net/note/delete/71962 Reject -- https://master.php.net/note/reject/71962 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120925) next »