note 88254 deleted from function.strip-tags by aharvey

From: Date: Thu, 20 Sep 2012 12:06:59 +0000
Subject: note 88254 deleted from function.strip-tags by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190915@lists.php.net to get a copy of this message
Note Submitter: phzzyzhou at gmail dot com ---- strip_tags will strip '<' and the string behind, like this <?php $str = <<<EOF 123 < 456 <a>link</a> bbb EOF; echo strip_tags($str); ?> will output: 123 --------------------------------- this function will repiar this <?php function will_strip_tags($str) { do { $count = 0; $str = preg_replace('/(<)([^>]*?<)/' , '&lt;$2' , $str , -1 , $count); } while ($count > 0); $str = strip_tags($str); $str = str_replace('>' , '&gt;' , $str); return $str; } echo will_strip_tags($str); ?> will output: 123 &lt; 456 link bbb

« previous php.notes (#190915) next »