note 71266 added to function.preg-replace

From: Date: Mon, 20 Nov 2006 09:39:44 +0000
Subject: note 71266 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-119892@lists.php.net to get a copy of this message
I am so dumb... I accidently changed something and posted before I tested it. This one works... Sorry bout that. <?php /** * strip_selected_tags ( string str [, string strip_tags[, strip_content flag]] ) * --------------------------------------------------------------------- * Like strip_tags() but inverse; the strip_tags tags will be stripped, not kept. * strip_tags: string with tags to strip, ex: "<a><p><quote>" etc. * strip_content flag: TRUE will also strip everything between open and closed tag */ function strip_selected_tags($str, $tags = "", $stripContent = false) { preg_match_all("/<([^>]+)>/i", $tags, $allTags, PREG_PATTERN_ORDER); foreach ($allTags[1] as $tag) { $replace = "%(<$tag.*?>)(.*?)(<\/$tag.*?>)%is"; if ($stripContent) { $str = preg_replace($replace,'',$str); } $str = preg_replace($replace,'${2}',$str); } return $str; } ?> ---- Server IP: 203.16.234.19 Probable Submitter: 220.236.195.36 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/71266 Del: integrated -- https://master.php.net/note/delete/71266/integrated Del: useless -- https://master.php.net/note/delete/71266/useless Del: bad code -- https://master.php.net/note/delete/71266/bad+code Del: spam -- https://master.php.net/note/delete/71266/spam Del: non-english -- https://master.php.net/note/delete/71266/non-english Del: in docs -- https://master.php.net/note/delete/71266/in+docs Del: other reasons-- https://master.php.net/note/delete/71266 Reject -- https://master.php.net/note/reject/71266 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119892) next »