Skip to content

Instantly share code, notes, and snippets.

View theozsnowman's full-sized avatar

Steve Kemp theozsnowman

View GitHub Profile
@salipro4ever
salipro4ever / PHP Clean String of UTF8 Chars – Convert to similar ASCII char
Created November 6, 2014 03:44
PHP Clean String of UTF8 Chars – Convert to similar ASCII char
/**
* Returns an string clean of UTF8 characters. It will convert them to a similar ASCII character
* www.unexpectedit.com
*/
function cleanString($text) {
// 1) convert á ô => a o
$text = preg_replace("/[áàâãªä]/u","a",$text);
$text = preg_replace("/[ÁÀÂÃÄ]/u","A",$text);
$text = preg_replace("/[ÍÌÎÏ]/u","I",$text);
$text = preg_replace("/[íìîï]/u","i",$text);