Created
November 18, 2013 14:54
-
-
Save smalot/7529083 to your computer and use it in GitHub Desktop.
PHP function which removes accent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Found on http://www.weirdog.com/blog/php/supprimer-les-accents-des-caracteres-accentues.html | |
*/ | |
function wd_remove_accents($str, $charset='utf-8') { | |
$str = htmlentities($str, ENT_NOQUOTES, $charset); | |
$str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str); | |
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ' | |
$str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment