/*
* function elimina_acentos [ $cadena string ]
* Elimina caracteres especiales y acentos
*/
function elimina_acentos($cadena){
$text_html = htmlentities($cadena, ENT_QUOTES, 'UTF-8');
$text = strtolower($text_html);
$patron = array (
/* Espacios, puntos y comas por guion
'/[\, ]+/' => '-',*/
// Vocales
'/à/' => 'a',
'/è/' => 'e',
'/ì/' => 'i',
'/ò/' => 'o',
'/ù/' => 'u',
'/á/' => 'a',
'/é/' => 'e',
'/í/' => 'i',
'/ó/' => 'o',
'/ú/' => 'u',
'/â/' => 'a',
'/ê/' => 'e',
'/î/' => 'i',
'/ô/' => 'o',
'/û/' => 'u',
'/ã/' => 'a',
'/&etilde;/' => 'e',
'/ĩ/' => 'i',
'/õ/' => 'o',
'/ũ/' => 'u',
'/ä/' => 'a',
'/ë/' => 'e',
'/ï/' => 'i',
'/ö/' => 'o',
'/ü/' => 'u',
'/ä/' => 'a',
'/ë/' => 'e',
'/ï/' => 'i',
'/ö/' => 'o',
'/ü/' => 'u',
// Otras letras y caracteres especiales
'/å/' => 'a',
'/ñ/' => 'n',
// Agregar aqui mas caracteres si es necesario
'/ /' => '_', // Espacio
);
$text_replace = preg_replace(array_keys($patron),array_values($patron),$text);
$text_str = str_replace("'","",$text_replace); #eliminar comillas simples
return $text_str;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.