Skip to content

Instantly share code, notes, and snippets.

@AlexSJ
Created June 26, 2014 17:08
Show Gist options
  • Save AlexSJ/e8afc003d817d86f2647 to your computer and use it in GitHub Desktop.
Save AlexSJ/e8afc003d817d86f2647 to your computer and use it in GitHub Desktop.
Helper para remover acentos das strings
<?php
class Helper {
/**
* Remove acentos das strings
*/
public static function removerAcentos($string) {
return strtr($string, array (
'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a',
'ç' => 'c',
'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i',
'ð' => 'o', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o',
'ñ' => 'n',
'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y',
'þ' => 'b',
'ÿ' => 'y'));
}
}
echo Helper::removerAcentos('áéíçãõúñ');
@paulodiovani
Copy link

strtr($string, 'àáâãäåæçèéêëìíîïðòóôõöøñùúûýþÿ', 'aaaaaaaceeeeiiiiooooooonuuuyby');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment