How can I escape 'special chars' in PHP, regardless of in which enc-type they are? Like so:
INPUT: ë, ë
OUTPUT: e, e
I hope someone can help. Thanks in advance!
How can I escape 'special chars' in PHP, regardless of in which enc-type they are? Like so:
INPUT: ë, ë
OUTPUT: e, e
I hope someone can help. Thanks in advance!
Try starting with this:
function replace_accents($str) {
$str = htmlentities($str, ENT_COMPAT, "UTF-8");
$str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str);
return html_entity_decode($str);
}
This function will convert all the accented chars into normal ones.
did some quick coding for this.
<?php
function correctWord($val) {
return iconv('UTF-8','ASCII//TRANSLIT', html_entity_decode($val));
}
echo correctWord("ë, ë");
found the fix in accented character from this Replacing accented characters php