Mega Code Archive

 
Categories / Php / Strings
 

Escape a character in HTML

<?php   $html = "<p> replace > and >> and >>> </p>";   print "<b>Original text was: '" . $html . "'\n";   $html = strrev( $html );   $newhtml = preg_replace( "/>(?![^><]+?\/?<)/", ";tl&", $html );   $newhtml = strrev( $newhtml );   print "<b>New text is: '" . $newhtml . "'\n"; ?>