Php Remove only given html tags from string
by Subramanian[ Edit ] 2014-07-15 15:57:28
Php Remove only given html tags from string :
PHP Function :
function stripeParticularTag($tags_to_strip,$str,$replace_with)
{
foreach ($tags_to_strip as $tag)
{
$str = preg_replace("$tag",$replace_with,$str);
}
return $str;
}
Eg:
$tags_to_strip = Array("p","font" );
$str="<p> </p><b>GvSubhu</b><font>SS</font>";
$replace_with = "";
echo stripeParticularTag($tags_to_strip,$str,$replace_with);
O/p : <b>GvSubhu</b>