note 100054 deleted from function.strip-tags by danbrown

From: Date: Fri, 23 Sep 2011 16:00:20 +0000
Subject: note 100054 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183373@lists.php.net to get a copy of this message
Note Submitter: gagomat at gmail dot com ---- here's the improved strip_only function (originally submitted by LWC / steve). This one can distinguish between <bla> and <blas> <?php function strip_only_tags($str, $tags, $stripContent=false) { $content = ''; if(!is_array($tags)) { $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) { if ($stripContent) $content = '(.+</'.$tag.'(>|\s[^>]*>)|)'; $str = preg_replace('#</?'.$tag.'(>|\s[^>]*>)'.$content.'#is', '', $str); } return $str; } ?>

« previous php.notes (#183373) next »