Wednesday, July 25, 2012

PHP: decode HTML special Chars


<?php
$str = "<p>this -&gt; &quot;</p>\n";


echo htmlspecialchars_decode($str); // <p>this -> "</p>


// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES); // <p>this -> &quot;</p>
?>


Reference:
http://php.net/manual/en/function.htmlspecialchars-decode.php

No comments: