How Get the Special Character list from a HTML string

342 Views Asked by At

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?

1

There are 1 best solutions below

2
On
$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);