note 106098 deleted from function.strip-tags by aharvey

From: Date: Thu, 20 Sep 2012 12:15:07 +0000
Subject: note 106098 deleted from function.strip-tags by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190927@lists.php.net to get a copy of this message
Note Submitter: dhgouveia at hotmail dot com ---- this is just for strip the inside tags <?php $allow = '<p><ul><li><b><strong>'; $str = '<p style="text-align:center">Paragraph</p><strong>Bold</strong><br/><span style="color:red">Red</span><h1>Header</h1>'; $result = strip_tags($str,$allow); $result = clean_inside_tags($result,$allow); echo '<textarea>'.$result.'</textarea>'; //Clean the inside of the tags function clean_inside_tags($txt,$tags){ preg_match_all("/<([^>]+)>/i",$tags,$allTags,PREG_PATTERN_ORDER); foreach ($allTags[1] as $tag){ $txt = preg_replace("/<".$tag."[^>]*>/i","<".$tag.">",$txt); } return $txt; } ?>

« previous php.notes (#190927) next »