note 76045 added to function.strip-tags
| From: | MatthieuLarcher at osu1 dot php dot net | Date: | Wed, 27 Jun 2007 15:44:45 +0000 |
| Subject: | note 76045 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128031@lists.php.net to get a copy of this message | ||
I noticed some problems with the strip_selected_tags() function below, sometimes big chunks of
contents where suppressed...
Here is a modified version that should run better.
<?php
function strip_selected_tags($text, $tags = array())
{
$args = func_get_args();
$text = array_shift($args);
$tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags;
foreach ($tags as $tag){
while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag
.'>/iusU', $text, $found)){
$text = str_replace($found[0],$found[2],$text);
}
}
return
preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU',
'', $text);
}
?>
----
Server IP: 217.174.196.197
Probable Submitter: 82.101.58.161
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/76045
Del: integrated -- https://master.php.net/note/delete/76045/integrated
Del: useless -- https://master.php.net/note/delete/76045/useless
Del: bad code -- https://master.php.net/note/delete/76045/bad+code
Del: spam -- https://master.php.net/note/delete/76045/spam
Del: non-english -- https://master.php.net/note/delete/76045/non-english
Del: in docs -- https://master.php.net/note/delete/76045/in+docs
Del: other reasons-- https://master.php.net/note/delete/76045
Reject -- https://master.php.net/note/reject/76045
Search -- https://master.php.net/manage/user-notes.php