PDA

View Full Version : undo html



vividona
02-16-2010, 08:09 AM
I am using htmlspecialchars() function to change some of html tags

Now I need to highlight my php codes.


public function bb_php($string)
{
string = str_replace ( '&', '&', $string );
$string = str_replace ( ''', '', $string );
$string = str_replace ( '"', '', $string );
$string = str_replace ( '&lt;', '<', $string );
$string = str_replace ( '&gt;', '>', $string );

$match = array('#\[php\](.*?)\[\/php\]#se');
$replace = array("'<div>'.highlight_string(stripslashes('$1'), true).'</div>'");

return preg_replace($match, $replace, $string);
}

This code undo html tags from the whole page.
I need to remove it only from php codes