note 93414 added to function.strip-tags
| From: | dan at micamedia dot com | Date: | Wed, 09 Sep 2009 03:11:08 +0000 |
| Subject: | note 93414 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160339@lists.php.net to get a copy of this message | ||
re-wrote the strip_selected_tags function below to work for XHML self closing tags.
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;
}
----
Server IP: 208.69.120.35
Probable Submitter: 96.236.222.160
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/93414
Del: integrated -- https://master.php.net/note/delete/93414/integrated
Del: useless -- https://master.php.net/note/delete/93414/useless
Del: bad code -- https://master.php.net/note/delete/93414/bad+code
Del: spam -- https://master.php.net/note/delete/93414/spam
Del: non-english -- https://master.php.net/note/delete/93414/non-english
Del: in docs -- https://master.php.net/note/delete/93414/in+docs
Del: other reasons-- https://master.php.net/note/delete/93414
Reject -- https://master.php.net/note/reject/93414
Search -- https://master.php.net/manage/user-notes.php