note 75100 added to function.strip-tags
| From: | geersc at hotmail dot com | Date: | Sat, 12 May 2007 10:13:12 +0000 |
| Subject: | note 75100 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126427@lists.php.net to get a copy of this message | ||
Hi,
I made the following adjustments to the "stripeentag()" function listed here.
Improvements are always welcome.
Regards,
Chris
<?php
function strip_attributes($msg, $tag, $attr, $suffix = "")
{
$lengthfirst = 0;
while (strstr(substr($msg, $lengthfirst), "<$tag ") != "")
{
$tag_start = $lengthfirst + strpos(substr($msg, $lengthfirst), "<$tag ");
$partafterwith = substr($msg, $tag_start);
$img = substr($partafterwith, 0, strpos($partafterwith, ">") + 1);
$img = str_replace(" =", "=", $img);
$out = "<$tag";
for($i=0; $i < count($attr); $i++)
{
if (empty($attr[$i])) {
continue;
}
$long_val =
(strpos($img, " ", strpos($img, $attr[$i] . "=")) === FALSE) ?
strpos($img, ">", strpos($img, $attr[$i] . "=")) - (strpos($img,
$attr[$i] . "=") + strlen($attr[$i]) + 1) :
strpos($img, " ", strpos($img, $attr[$i] . "=")) - (strpos($img,
$attr[$i] . "=") + strlen($attr[$i]) + 1);
$val = substr($img, strpos($img, $attr[$i] . "=" ) + strlen($attr[$i]) + 1,
$long_val);
if (!empty($val)) {
$out .= " " . $attr[$i] . "=" . $val;
}
}
if (!empty($suffix)) {
$out .= " " . $suffix;
}
$out .= ">";
$partafter = substr($partafterwith, strpos($partafterwith,">") + 1);
$msg = substr($msg, 0, $tag_start). $out. $partafter;
$lengthfirst = $tag_start + 3;
}
return $msg;
}
?>
----
Server IP: 193.190.198.20
Probable Submitter: 84.196.97.99
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/75100
Del: integrated -- https://master.php.net/note/delete/75100/integrated
Del: useless -- https://master.php.net/note/delete/75100/useless
Del: bad code -- https://master.php.net/note/delete/75100/bad+code
Del: spam -- https://master.php.net/note/delete/75100/spam
Del: non-english -- https://master.php.net/note/delete/75100/non-english
Del: in docs -- https://master.php.net/note/delete/75100/in+docs
Del: other reasons-- https://master.php.net/note/delete/75100
Reject -- https://master.php.net/note/reject/75100
Search -- https://master.php.net/manage/user-notes.php