Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> 

into:

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

html_entity_decode() did not work.

like image 387
tzmatt7447 Avatar asked Aug 26 '10 11:08

tzmatt7447


People also ask

Which PHP function converts HTML into a format that can be displayed but will not be interpreted as HTML by a browser?

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.

What is HTML decoding?

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 &lt; and &gt; for HTTP transmission.

How do you convert special characters in HTML?

The htmlspecialchars_decode() function converts some predefined HTML entities to characters. HTML entities that will be decoded are: &amp; becomes & (ampersand)


1 Answers

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)

like image 148
Robert Ros Avatar answered Sep 20 '22 02:09

Robert Ros