user2552863
user2552863

Reputation: 499

How Get the Special Character list from a HTML string

In my database I have saved,

<p>& sign test</p> <p><>greater than and less than</p>

I am using these for document download. I want replace these special characters & and <> with &amp; and &lt;&gt; respectively.

How can I detect special characters from the above html content?

Upvotes: -2

Views: 352

Answers (1)

Hammad Ahmed khan
Hammad Ahmed khan

Reputation: 1671

$orig = "I'll \"walk\" the <b>dog</b> now";

$a = htmlentities($orig);

$b = html_entity_decode($a);

echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now

echo $b; // I'll "walk" the <b>dog</b> now

or you can use your custom function if you dont want html tag to convert into unicode :

$text = str_replace(array("&quot;", "&amp;"), array("\"", "&"), $text);

Upvotes: 1

Related Questions