> So my question is, should I (or, really, can I) encode it?  My thinking is I
> want to encode it with the htmlspecialchars() function... however,
> eventually, all the data within the Hidden Input Boxes will be stored into
> my mySQL database, so I'll want to decode it before I send it (restoring the
> quotes)... is there a way to decode the htmlspecialchars() function?

I ran into almost exactly the same problem.  I was about ready to break
down and hack out a regex when I came across the
get_html_translation_table() function.  This function lets you get the
translation table used for the htmlspecialchars and htmlentities
functions.  So, for example:

function my_htmlspecialchars ($string) {
        $trans_table = get_html_translation_table (HTML_SPECIALCHARS);
        return strtr($string, $trans_table);
}

This uses the strtr (STRing TRanslate) function to do the translation and
does exactly the same thing as php's native htmlspecialchars().  To
reverse things (replace the special chars with normal chars), we just need
to flip the $trans_table around

function strip_htmlspecialchars ($string) {
        $trans_table = get_html_translation_table (HTML_SPECIALCHARS);
        $trans_table = array_flip($trans_table);
        return strtr($string, $trans_table);
}


There ya go :)


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to