PHP html decoding help – converting: A &#039;quote&#039; is <b>bold</b>

I need to convert a string like this:

A &#039;quote&#039; is <b>bold</b>


A 'quote' is <b>bold</b>

html_entity_decode() did not work.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Make sure you use the right quote_style:

html_entity_decode('A &#039;quote&#039; is <b>bold</b>', ENT_QUOTES);

ENT_QUOTES Will convert both double and single quotes. (PHP Manual: html_entity_decode)

Solution 2

mb_convert_encoding($string, "UTF-8", "HTML-ENTITIES");

You can replace “UTF-8” with whatever encoding you need (though depending on the encoding you choose, certain characters may not be representable).

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply