PHP html decoding help - converting: A 'quote' is bold

后端 未结 2 1098
天涯浪人
天涯浪人 2020-12-06 04:32

I need to convert a string like this:

A 'quote' is bold

into:

A \'quote\' is 

        
相关标签:
2条回答
  • 2020-12-06 04:39

    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)

    0 讨论(0)
  • 2020-12-06 04:57
    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).

    0 讨论(0)
提交回复
热议问题