note 71370 added to function.strip-tags
| From: | (googleityourself:P) | Date: | Fri, 24 Nov 2006 17:08:56 +0000 |
| Subject: | note 71370 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120056@lists.php.net to get a copy of this message | ||
This is Salaverts function improved with suggestions from this page as it has been refactored forthe
Akelos Framework (http://www.akelos.org) by Jose Salavert
Please note that the "u" modifier need to be lowercased. This function will also replace
self-closing tags (XHTML <br /> <hr />) and will work if the text contains line breaks.
<?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){
if(preg_match_all('/<'.$tag.'[^>]*>((\\n|\\r|.)*)<\/'. $tag
.'>/iu', $text, $found)){
$text = str_replace($found[0],$found[1],$text);
}
}
return
preg_replace('/(<('.join('|',$tags).')(\\n|\\r|.)*\/>)/iu',
'', $text);
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 83.50.38.23
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/71370
Del: integrated -- https://master.php.net/note/delete/71370/integrated
Del: useless -- https://master.php.net/note/delete/71370/useless
Del: bad code -- https://master.php.net/note/delete/71370/bad+code
Del: spam -- https://master.php.net/note/delete/71370/spam
Del: non-english -- https://master.php.net/note/delete/71370/non-english
Del: in docs -- https://master.php.net/note/delete/71370/in+docs
Del: other reasons-- https://master.php.net/note/delete/71370
Reject -- https://master.php.net/note/reject/71370
Search -- https://master.php.net/manage/user-notes.php