Question

I stored HTML to my database:

$ohtml = htmlentities($html);

But when I retrieve the data by using

$new_html = html_entity_decode($ohtml, ENT_QUOTES);

The data displayed is alright but I want to to be converted to real HTML not just display the codes. Ex. I want to display a textarea if the $new_html = "<textarea> </textarea>";

Was it helpful?

Solution

Just echo the $new_html.

$new_html = html_entity_decode($ohtml, ENT_QUOTES);
echo $new_html;

EDIT: Slow I am.. Trying to understand his question took so long others already posted comments with the solution...

EDIT2: Try this code, it's working for me:

$html = "<b>I hate entities</b>";

$ohtml = htmlentities($html);

$new_html = html_entity_decode($ohtml, ENT_QUOTES);
echo $new_html;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top