Created
September 26, 2011 19:27
-
-
Save deyvin/1243154 to your computer and use it in GitHub Desktop.
removendo Acentos com php
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
<? | |
function removeAcentos($str) { | |
$enc = (mb_detect_encoding($str, 'UTF-8', true)) ? 'UTF-8' : 'ISO-8859-1'; | |
$acentos = array('A' => '/À|Á|Â|Ã|Ä|Å/', | |
'a' => '/à|á|â|ã|ä|å/', | |
'C' => '/Ç/', | |
'c' => '/ç/', | |
'E' => '/È|É|Ê|Ë/', | |
'e' => '/è|é|ê|ë/', | |
'I' => '/Ì|Í|Î|Ï/', | |
'i' => '/ì|í|î|ï/', | |
'N' => '/Ñ/', | |
'n' => '/ñ/', | |
'O' => '/Ò|Ó|Ô|Õ|Ö/', | |
'o' => '/ò|ó|ô|õ|ö/', | |
'U' => '/Ù|Ú|Û|Ü/', | |
'u' => '/ù|ú|û|ü/', | |
'Y' => '/Ý/', | |
'y' => '/ý|ÿ/', | |
'a.' => '/ª/', | |
'o.' => '/º/'); | |
return strtoupper(preg_replace($acentos, array_keys($acentos), htmlentities($str, ENT_NOQUOTES, $enc))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment