Site icon Shaharia's Blog

Decode HTML entities from the Strings

Sometimes we need to decode HTML entities from any specific strings in PHP. Basically it’s more used for retrieve HTML entities from a MySQL cell.? To Convert all HTML entities to their applicable characters there is one function available that is called html_entity_decode().

html_entity_decode($YourStrings)

Example:

<?php
$orig?=?"I'll?"love"?the?<b>girl</b> very much";

$a?=?htmlentities($orig);

$b?=?html_entity_decode($a);

echo?$a;?//?I'll?&quot;love&quot;?the?&lt;b&gt;girl&lt;/b&gt; very much

echo?$b;?//?I'll?"love"?the?<b>girl</b> very much?>

Exit mobile version