htmlentities / html_entity_decode

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I've been having problems encoding / decoding data, and can't seem to
figure out where I am going wrong.

I extract data from a mysql table with a line like:

$object_name[$a] = stripslashes(htmlspecialchars($row['object_name'],

so an entry called, say,  '"Y" axis' becomes '"Y" axis'

OK so far...but when I use the line below to decode:

 echo html_entity_decode($object_name[$z], ENT_QUOTES);

it stills reads it out as : '"Y" axis'

What point am I missing here ?


Re: htmlentities / html_entity_decode

The html_entity_decode function is a newer function.  Try this if you
are using an older version of PHP:

// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities($string)
   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
   $trans_tbl = array_flip($trans_tbl);
   return strtr($string, $trans_tbl);

Site Timeline