Q:

Convert numeric entities to UTF-8

How can I replace all numeric entities with the appropriate UTF-8? 
For example: in the source the string shows like this:
$string1 = "The Devil&#39;s in the Details";
$string2 = "D&#xF3;nde est&#xE1;s, hermano?";

And I need replace it with
echo string1; //OUTPUTS Should be: The Devil's in the details
echo string2; //OUTPUTS Should be: Dónde Estás, Hermano?

I tried html_entity_decode() but it didn't work; any ideas?

A:

If the problem with html_entity_decode was that it didn’t decode the &#39;, it’s because the default flags are set to decode everything but a single quote. Do not attempt to ask why this is; it is PHP.
Try ENT_QUOTES:
html_entity_decode($str, ENT_QUOTES | ENT_HTML5); # HTML5 is good

That appears to work.

