Last active
October 21, 2015 16:23
-
-
Save mig1098/505467fc555c94c372cd to your computer and use it in GitHub Desktop.
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 cleanString($text) { | |
$utf8 = array( | |
'/[áàâãªä]/u' => 'a', | |
'/[ÁÀÂÃÄ]/u' => 'A', | |
'/[ÍÌÎÏ]/u' => 'I', | |
'/[íìîï]/u' => 'i', | |
'/[éèêë]/u' => 'e', | |
'/[ÉÈÊË]/u' => 'E', | |
'/[óòôõºö]/u' => 'o', | |
'/[ÓÒÔÕÖ]/u' => 'O', | |
'/[úùûü]/u' => 'u', | |
'/[ÚÙÛÜ]/u' => 'U', | |
'/ç/' => 'c', | |
'/Ç/' => 'C', | |
'/ñ/' => 'n', | |
'/Ñ/' => 'N', | |
'/–/' => '-', // UTF-8 hyphen to "normal" hyphen | |
'/[’‘‹›‚]/u' => ' ', // Literally a single quote | |
'/[“”«»„]/u' => ' ', // Double quote | |
'/ /' => ' ', // nonbreaking space (equiv. to 0x160) | |
'/\r?\n/u' => '', | |
'/u201/m' => '"', | |
'/u00a0/m' => '', | |
'/ /' => ' ' | |
); | |
return preg_replace(array_keys($utf8), array_values($utf8), $text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment