Skip to content

Instantly share code, notes, and snippets.

@petronioamaral
Created August 13, 2020 19:03
Show Gist options
  • Save petronioamaral/466cd3bee9eaf0f6573bad5a7889c7f3 to your computer and use it in GitHub Desktop.
Save petronioamaral/466cd3bee9eaf0f6573bad5a7889c7f3 to your computer and use it in GitHub Desktop.
remove accents php
  public function removerAcentos($str){
        $str = preg_replace('/[áàãâä]/ui', 'a', $str);
        $str = preg_replace('/[éèêë]/ui', 'e', $str);
        $str = preg_replace('/[íìîï]/ui', 'i', $str);
        $str = preg_replace('/[óòõôö]/ui', 'o', $str);
        $str = preg_replace('/[úùûü]/ui', 'u', $str);
        $str = preg_replace('/[ç]/ui', 'c', $str);
        $str = preg_replace('/[^a-z0-9]/i', ' ', $str);
        // $str = preg_replace('/_+/', ' ', $str);
        $str = preg_replace('/\s+/', ' ', $str);

        return $str;

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