Why is html_entity_decode() working for the first string, but not the second?

Viewed 59
$string1 = 'Cotton Lanyard ½"';
$string2 = 'Organic Cotton Lanyard ⅝"';

echo html_entity_decode($string1); //Cotton Lanyard ½"
echo html_entity_decode($string2); //Organic Cotton Lanyard ⅝"

Not really sure how to fix this?

1 Answers

It works with an HTML5 document type flag.

echo html_entity_decode($string2, ENT_HTML5);   // Organic Cotton Lanyard ⅝"

Since the default type is ENT_HTML401 (HTML 4.01), I suppose that means the ⅝ entity isn't defined there.

Related