Skip to content

Instantly share code, notes, and snippets.

@andrefrd
Last active August 29, 2015 14:05
Show Gist options
  • Save andrefrd/ce24874ffee20776f249 to your computer and use it in GitHub Desktop.
Save andrefrd/ce24874ffee20776f249 to your computer and use it in GitHub Desktop.
header ('Content-type: text/html; charset=UTF-8');
function generate_sef_urls ( $input, $replace = '-', $remove_words = true, $words_array = array() ){
$return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
return str_replace(' ',$replace,$return);
}
$palavra = "Remoção de Acentos e Criador de SEF";
$comAcentos = array('à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ü', 'ú', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'O', 'Ù', 'Ü', 'Ú');
$semAcentos = array('a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'y', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'o', 'U', 'U', 'U');
$palavra = str_replace($comAcentos, $semAcentos, $palavra);
$badWords = array('de','para');
$newSefUrl = generate_sef_urls ( $palavra, '-' , false , $badWords);
echo $newSefUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment