Adrien Parad
Adrien Parad

Reputation: 63

PHP - How can I decode HTML special character strings to the actual characters?

I have some text, for example: “ £   € “ I would like to decode it, so it outputs: £ €

I tried this code, but it doesn't work:

utf8_decode($utf8);
iconv('UTF-8', 'ISO-8859-1', $utf8);
mb_convert_encoding($utf8, 'ISO-8859-1', 'UTF-8');

utf8_encode($iso88591);
iconv('ISO-8859-1', 'UTF-8', $iso88591);
mb_convert_encoding($iso88591, 'UTF-8', 'ISO-8859-1');

I don't want to do a str_replace for each character.

Upvotes: 1

Views: 615

Answers (1)

Nilesh Lathe
Nilesh Lathe

Reputation: 152

echo html_entity_decode('“ £   € “');

Upvotes: 2

Related Questions