Skip to content

Instantly share code, notes, and snippets.

@calevano
Created December 13, 2017 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calevano/45a00a5aa9ff89ed2e9269f09652522c to your computer and use it in GitHub Desktop.
Save calevano/45a00a5aa9ff89ed2e9269f09652522c to your computer and use it in GitHub Desktop.
<?hp
function url_amigable($url) {
//$urlMinuscula = strtolower($url);
$buscarLetra = array('Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ', 'á', 'é', 'í', 'ó', 'ú', 'ñ');
$reemplazar = array('A', 'E', 'i', 'O', 'U', 'N', 'a', 'e', 'i', 'o', 'u', 'n');
$urlNueva = str_replace($buscarLetra, $reemplazar, $url);
$buscarCaracteres = array(' ', '&', '\r\n', '\n', '+');
$urlAceptable = str_replace($buscarCaracteres, ' ', $urlNueva);
//$find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
//$repl = array('', '-', '');
//$urlRetornar = preg_replace($find, ' ', $urlAceptable);
return $urlAceptable;
}
$mensaje = 'Húmberto á - " enrique *][___?=?)=(= ashdasd Ámparo ';
echo url_amigable($mensaje);
@calevano
Copy link
Author

Clean tilde and caracter special in text

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