In many cases we add content in the database with replacing all html tags into special characters. But it generate problems when we want to show at front side. So here we are giving a best solution to show result as HTML:
function __htmlConvertor($str)
{
$string = str_replace(array("<", ">", '&', ''', '"','<', '>'), array("<", ">",'&','\'','"','<','>'), htmlspecialchars_decode($str, ENT_NOQUOTES));
return $string;
}
and will return the code in the html format. Here are giving an example so you can understand in better way:
Above function takes the string from the database (manually send)
Before
<div>
naveenos group
</div>
<table>
<tr>
<td>
http://naveenos.com
</td>
</tr>
</table>
After called to this function:
<div>
naveenos group
</div>
<table>
<tr>
<td>http://naveenos.com</td>
</tr>
</table>
Leave a Reply