Last active
August 6, 2019 19:50
-
-
Save diefferson/d745ec0ce13a5565de2882b99405e2cd to your computer and use it in GitHub Desktop.
Função Para substituir caracteres com acentos por caracteres comuns
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
<?php | |
function removerAcentos( $string ) { | |
$mapaAcentosHex = array( | |
'a'=> '/[\xE0-\xE6]/', | |
'A'=> '/[\xE0-\xE6]/', | |
'e'=> '/[\xE8-\xEB]/', | |
'E'=> '/[\xE8-\xEB]/', | |
'i'=> '/[\xEC-\xEF]/', | |
'I'=> '/[\xEC-\xEF]/', | |
'o'=> '/[\xF2-\xF6]/', | |
'O'=> '/[\xF2-\xF6]/', | |
'u'=> '/[\xF9-\xFC]/', | |
'U'=> '/[\xF9-\xFC]/', | |
'c'=> '/\xE7/', | |
'C'=> '/\xE7/', | |
'n'=> '/\xF1/', | |
'N'=> '/\xF1/' | |
); | |
foreach ($mapaAcentosHex as $letra => $expressaoRegular) { | |
$string = preg_replace( $expressaoRegular, $letra, $string); | |
} | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment