Skip to content

Instantly share code, notes, and snippets.

@josecarlosqs
Last active April 20, 2016 21:28
Show Gist options
  • Save josecarlosqs/a81c9a6ef182019a52d1cbba25af48dc to your computer and use it in GitHub Desktop.
Save josecarlosqs/a81c9a6ef182019a52d1cbba25af48dc to your computer and use it in GitHub Desktop.
<?php
// Replace special chars to a alphabetical equivalent.
function normalizar($str){
$chars = array('á','Á','à','À','â','Â','å','Å','ã','Ã','ä','Ä','æ','Æ','ç','Ç','é','É','è','È','ê','Ê','ë','Ë','í','Í','ì','Ì','î','Î','ï','Ï','ñ','Ñ','ó','Ó','ò','Ò','ô','Ô','ø','Ø','õ','Õ','ö','Ö','ß','ú','Ú','ù','Ù','û','Û','ü','Ü','ÿ');
$replacement = array('a','A','a','A','a','A','a','A','a','A','a','A','ae','AE','c','C','e','E','e','E','e','E','e','E','i','I','i','I','i','I','i','I','n','N','o','O','o','O','o','O','o','O','o','O','o','O','B','u','U','u','U','u','U','u','U','y');
return str_replace($chars,$replacement,$str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment