Q:

PHP cleanup "&$"

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have tried:

html2text command line
html_entity_decode + ENT_QUOTES | ENT_HTML401 UTF-8
html_entity_decode(htmlentities($str))
strip_tags
trim

It did help a lot for cleaning up other things, but those &\#8217; &#8220; don't get fixed. How can I convert them correctly?

A:

Did you tried "htmlspecialchars_decode"
<?php
$str = "<p>this -&gt; &quot;</p>\n";
echo htmlspecialchars_decode($str);
// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>

The above example will output:
<p>this -> "</p>
<p>this -> &quot;</p>

