Created
August 18, 2021 23:56
-
-
Save bobwol/3e750331c156e584ba526b4bf5ecad26 to your computer and use it in GitHub Desktop.
Tirar acentos, caracteres especiais e espaços de titulos e frases para torna-los slug
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
<?php | |
function tirarAcentos($string){ | |
$string = preg_replace(array("/(á|à|ã|â|ä)/","/(Á|À|Ã|Â|Ä)/","/(é|è|ê|ë)/","/(É|È|Ê|Ë)/","/(í|ì|î|ï)/","/(Í|Ì|Î|Ï)/","/(ó|ò|õ|ô|ö)/","/(Ó|Ò|Õ|Ô|Ö)/","/(ú|ù|û|ü)/","/(Ú|Ù|Û|Ü)/","/(ñ)/","/(Ñ)/","/(ç)/","/(Ç)/"),explode(" ","a A e E i I o O u U n N c C"),$string); | |
$char = array(' & ', 'ª ', ' (', ') ', '(', ')', ' - ', ' / ', ' /', '/ ', '/', ' | ', ' |', '| ', ' | ', '|', '_', '.', ' '); | |
return strtolower(str_replace($char, '-', $string)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment