If I have code converted using htmlspecialchars how can i reverse it? I have searched and searched...
Thanks
Darren
You might have to make a function:
here is one you could use:
<?php
function reverseHtmlSpecialChars($variable){ $variable = eregi_replace("&", "&", $variable); //Etc... add more here: for example <, > ... return($variable); }
?>
// This is constructed from reading // the php4 documentation // WARNING: untested code
function unhtmlspecialchars($str) { // get the translation table $trans = get_html_translation_table(HTML_SPECIALCHARS); // reverse the order of translation $trans = array_flip($trans); // apply it and return the result return strtr($str, $trans); }
Do You need a solution for php3? But this following function is slowly. You should optimize.
function htmlentities_to_str($str) {
for ($i=255; $i>=32; $i--) { $chr=chr($i); $code=htmlentities($chr); if ($code != $chr) $str=str_replace($code, $chr, $str); } return $str; }