Cla
Cla

Reputation: 1938

Why html_entities_decode is not decoding the html entities?

I have this code:

$string = "Perfect Valentine's Day Care Package | SpouseBuzz.com";
echo $string ."\n";
echo html_entity_decode($string) ."\n";

And it returns:

Perfect Valentine's Day Care Package | SpouseBuzz.com
Perfect Valentine's Day Care Package | SpouseBuzz.com

My question is: why html_entity_decode is not converting the html entity?

Thanks!

Upvotes: 0

Views: 262

Answers (1)

Amal
Amal

Reputation: 76676

html_entity_decode() by default will only convert double-quotes and will leave single-quotes alone. To also convert single-quotes to their corresponding character, add the ENT_QUOTES flag:

echo html_entity_decode($string, ENT_QUOTES, 'UTF-8');

Online demo

Upvotes: 3

Related Questions