note 89967 added to function.strip-tags
| From: | nick at optixsolutions dot co dot uk | Date: | Tue, 31 Mar 2009 07:57:00 +0000 |
| Subject: | note 89967 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152645@lists.php.net to get a copy of this message | ||
An improvement on my previous strip tags/attributes (with allowable tags/attributes) function (it
broke if there were no attributes in the code):
function strip_tags_attributes($string,$allowtags=NULL,$allowattributes=NULL){
if($allowattributes){
if(!is_array($allowattributes))
$allowattributes = explode(",",$allowattributes);
if(is_array($allowattributes))
$allowattributes = implode("|",$allowattributes);
$rep = '/([^>]*)
('.$allowattributes.')(=)(\'.*\'|".*")/i';
$string = preg_replace($rep, '$1 $2_-_-$4', $string);
}
if(preg_match('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i',$string) >
0){
$string = preg_replace('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i',
'$1$4', $string);
}
$rep = '/([^>]*)
('.$allowattributes.')(_-_-)(\'.*\'|".*")/i';
if($allowattributes)
$string = preg_replace($rep, '$1 $2=$4', $string);
return strip_tags($string,$allowtags);
}
----
Server IP: 87.124.35.190
Probable Submitter: 82.33.205.169
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/89967
Del: integrated -- https://master.php.net/note/delete/89967/integrated
Del: useless -- https://master.php.net/note/delete/89967/useless
Del: bad code -- https://master.php.net/note/delete/89967/bad+code
Del: spam -- https://master.php.net/note/delete/89967/spam
Del: non-english -- https://master.php.net/note/delete/89967/non-english
Del: in docs -- https://master.php.net/note/delete/89967/in+docs
Del: other reasons-- https://master.php.net/note/delete/89967
Reject -- https://master.php.net/note/reject/89967
Search -- https://master.php.net/manage/user-notes.php