Saturday, May 17, 2008

Remove/Block specific HTML tag

<?php

$string = '<EM>see</EM>  <A href="http://www.epicurious.com/cooking/how_to/food_dictionary/entry?id=1965"><FONT size=-1>CLOUDBERRY</FONT></A>';

$tag = "A";

$regExp = "<" . "$tag" . "[^>]*>";

$string = str_replace("</$tag>", "", $string);
$string = ereg_replace($regExp, "", $string);

echo $string;


?>

No comments: