html_entity_decode does not decode

I have a problem with decoding html entities for browser display.
I’m trying to display the blog description from a wordpress blog. The text is being html entity encoded before it is saved in the db. So in order to display, for instance, a hyper link the text has to be html entity decoded back, so the a-tag is being rendered properly.

But when I try to decode the text it still comes out as html entities.

Read More

The output before being decoded:

echo(bloginfo( 'description' )); //output: Display a hyper link. <a href="">READ MORE</a>

The output when being decoded. And here’s my problem. It is still not decoded! Check the output.

echo(html_entity_decode(bloginfo( 'description' ))); //output: Display a hyper link. <a href="">READ MORE</a>

And when I try to hard code the text to be decoded, it works!

echo(html_entity_decode('Display a hyper link. &lt;a href=""&gt;READ MORE&lt;/a&gt;')); //output: Display a hyper link. <a href="">READ MORE</a>

I’ve looked at the php manual, and tried different charsets and quote styles as arguments. But still no luck.

What am I doing wrong, any ideas?

Related posts

Leave a Reply

3 comments

  1. Are you sure bloginfo does not encode the characters another time?

    If it re-encodes them, your html_entity_decode will simply revert back to their original status (which is encoded).