I need to convert a string like this:
A 'quote' is <b>bold</b>
into:
A 'quote' is <b>bold</b>
html_entity_decode()
did not work.
To convert HTML into a format that can be displayed but will not be interpreted as HTML by a browser, use the PHP htmlentities function.
HTML encoding converts characters that are not allowed in HTML into character-entity equivalents; HTML decoding reverses the encoding. For example, when embedded in a block of text, the characters < and > are encoded as < and > for HTTP transmission.
The htmlspecialchars_decode() function converts some predefined HTML entities to characters. HTML entities that will be decoded are: & becomes & (ampersand)
Make sure you use the right quote_style:
html_entity_decode('A 'quote' is <b>bold</b>', ENT_QUOTES);
ENT_QUOTES Will convert both double and single quotes. (PHP Manual: html_entity_decode)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With