Reputation: 68680
$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>
Upvotes: 0
Views: 78
Reputation: 78994
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;
Upvotes: 2
Reputation: 1593
Try using "htmlspecialchars_decode()" instead of "html_entity_decode()"
Upvotes: 0