I have a string already parsed by htmlentities function. I need to be able to reverse the htmlentities function only for a certain tags. Anyone knows how can i do it? For example: filtertag('<b>') to <a href="http://www.asdasd.com">Link</a> <br><br><b>My bold text</b> HTML: Gives <a href="http://www.asdasdasd.com">Link</a> <br><br><b>My bold text</b> HTML: The function must be able to deal with any tag and reverse it.
Make an array of tags you want to reverse, such as: function filtertag( $string ) { $good_tags = array('<b>' => "<b>", '</b>' => "</b>"); foreach($good_tags as $start => $end) { str_replace($start, $end, $string); } return $string; } PHP: Hope that helps.
What if the tag works in a different way? For example img may be <img src="" class="x" alt=""...> The tag list is not fixed...its a variable that comes from admin settings.