note 32679 added to function.strip-tags

From: Date: Wed, 04 Jun 2003 10:58:34 +0000
Subject: note 32679 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-49704@lists.php.net to get a copy of this message
This routine removes all attributes from a given tag except the attributes specified in the array $attr. function stripeentag($msg,$tag,$attr) { $lengthfirst = 0; while (strstr(substr($msg,$lengthfirst),"<$tag ")!="") { $imgstart = $lengthfirst + strpos(substr($msg,$lengthfirst), "<$tag "); $partafterwith = substr($msg,$imgstart); $img = substr($partafterwith,0,strpos($partafterwith,">")+1); $img = str_replace(" =","=",$msg); $out = "<$tag"; for($i=1;$i<=count($atr);$i++) { $val = filter($img,$attr[$i]."="," "); if(strlen($val)>0) $attr[$i] = " ".$attr[$i]."=".$val; else $attr[$i] = ""; $out .= $attr[$i]; } $out .= ">"; $partafter = substr($partafterwith,strpos($partafterwith,">")+1); $msg = substr($msg,0,$imgstart).$out.$partafter; $lengthfirst = $imgstart+3; } return $msg; } ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32679 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32679&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32679&report=yes

« previous php.notes (#49704) next »