When using strip_tags and html_entity_decode with PHP it often breaks and produces annoying diamonds with question marks.
It is probably because of characters like these:
… (looks like 3 dots but it is a single weird character).
’ (looks like a normal apostraphe but it is not)
” (looks like a normal double quote but it is not).
An easy way to sort this out is to copy the above and search in an ASCII table to extend the functionality below.
Basically the first array has a list of "all the bad stuff" and the second array is what to replace it with.
<?
function CleanupSmartQuotes($text)
{
$badwordchars=array(
chr(145), // weird apostraphe
chr(146), // weird apostraphe
chr(147), // weird quote
chr(148), // weird quote
chr(151), // weird dash
chr(133), // three dots
' ',
);
$fixedwordchars=array(
"'",
"'",
'"',
'"',
'—',
'...',
'',
);
return str_replace($badwordchars,$fixedwordchars,$text);
}
?>
php, decoding, quotes, ascii, characterswhen, strip_tags, html_entity_decode, produces, characters, hellip, dots, rsquo, apostraphe, rdquo, extend, functionality, array, quot, cleanupsmartquotes, text, badwordchars, chr, dash, fixedwordchars, mdash, str_replace,