Clear accents easy and fast


/ Published in: PHP
Save to your folder(s)

It is a simple function that remove accents and puts its closest equivalent throught htmlentities and preg_replace, very useful for SEF url and aliases


Copy this code and paste it in your HTML
  1. function quitaAcentos($string,$lowercase=true) {
  2. $string = preg_replace('`&(\w)[^;]+;`','$1',htmlentities($string));
  3. $string = $lowercase ? strtolower($string) : $string;
  4. return $string;
  5. }
  6. // echo quitaAcentos("copón") will show "copon"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.