To remove all accents of a PHP string.


 * Remove accents of a string
function removeAccents($string, $charset="utf-8")
    $string = htmlentities($string, ENT_NOQUOTES, $charset);
    $string = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $string);
    $string = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $string); // ligatures e.g. 'œ'
    $string = preg_replace('#&[^;]+;#', '', $string); // remove escaped characters that are left
    return $string;


  • The idea is to escape all special characters first, then to replace them with a Regex
  • Better solution than the non-consistent iconv() PHP function



Keep Me Informed

Keep me informed of the latest extensions releases and offers. One email maximum per month.

Offer Me A Coffee!

If you like my work, offer me a coffee! Nick.