You may want to look at Matt Robinson's article on an alternative method: Converting named entities to numeric in PHP . It mentions the html_entity_decode
method (already pointed out by another answer) and some potential pitfalls:
There are two possible problems with this approach. The first is invalid entities: html_entity_decode()
won't touch them, which means you'll still get XML errors. The second is encoding. I suppose it's possible that you don't actually want UTF-8
. You should, because it's awesome, but maybe you have a good reason. If you don't tell html_entity_decode()
to use UTF-8
, it won't convert entities that don't exist in the character set you specify. If you tell it to output in UTF-8 and then use something like iconv()
to convert it, then you'll lose any characters that aren't in the output encoding.
Also, if you find the script rather cumbersome, you can also use the one shared on SourceRally.