31

I need to convert a string like this:

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

into:

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

html_entity_decode() did not work.

2 Answers 2

64

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)

1
  • That helps - thats exactly it - it worked fine after this! Thanks RObert!
    – tzmatt7447
    Aug 26, 2010 at 11:47
25
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).

1
  • its not wokring in my case Sep 13, 2021 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.