note 93414 deleted from function.strip-tags by danbrown

From: Date: Fri, 23 Sep 2011 16:01:11 +0000
Subject: note 93414 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183376@lists.php.net to get a copy of this message
Note Submitter: dan at micamedia dot com ---- re-wrote the strip_selected_tags function below to work for XHML self closing tags. <?php 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"; $replace2 = "%(<$tag.*?>)%is"; echo $replace; if ($stripContent) { $str = preg_replace($replace,'',$str); $str = preg_replace($replace2,'',$str); } $str = preg_replace($replace,'${2}',$str); $str = preg_replace($replace2,'${2}',$str); } return $str; } ?>

« previous php.notes (#183376) next »