$str = '<div style="text-align:center"><img src="http://image.gif" border="0">';
echo html_entity_decode($str,ENT_COMPAT, 'UTF-8');
Outputs the same:
<div style="text-align:center"><img src="http://image.gif" border="0">
I'm expecting:
<div style="text-align:center"><img src="http://image.gif" border="0"></div>
This has been double encoded, so you need to decode twice as &
needs to decode to &
in order to get <
etc...
echo html_entity_decode(html_entity_decode($str));
If you are doing the encoding then look at the $double_encode
parameter for htmlspecialchars()
and htmlentities()
.
If encoded multiple times then you could use:
while(($str = html_entity_decode($str)) != $str) {}
echo $str;
Try using "htmlspecialchars_decode()" instead of "html_entity_decode()"