Hey guys, I’m trying to use htmlentities() to convert the characters in a textarea to html codes. The code I have right now looks like this:
var_dump($colors);
$colors= htmlentities($colors, ENT_QUOTES, 'UTF-8', false);
var_dump($colors);
which returns this:
string(31) "• Red
• Green
• Blue<br />"
string(46) "• Red
• Green
• Blue<br />"
I assumed passing false to the double_encode parameter would prevent <br /> from being converted to <br />.
Any ideas?
The
double_encodeparameter prevents encoding existing html entities (e.g.•).<br />is not an html entity, so it gets encoded.