Created
October 21, 2013 13:31
-
-
Save samatsav/7083921 to your computer and use it in GitHub Desktop.
Inlocuieste diacriticele cu caractere compatibile ASCII. (@@todo: inainte de a folosii functia, a se scoate din $map conversiile in plus)
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
function ro_slugs($cuvant) { | |
$slug = trim(strtolower(stripslashes($cuvant))); | |
$map = array( | |
'/à|á|å|â|ă|â|Â|Ă|ă/i' => 'a', | |
'/è|é|ê|ẽ|ë/i' => 'e', | |
'/ì|í|î|î|Î|Î/i' => 'i', | |
'/ò|ó|ô|ø/i' => 'o', | |
'/ù|ú|ů|û/i' => 'u', | |
'/ș|ș|ş|Ș|Ș|Ş/i'=>'s', | |
'/ț|ţ|ț|Ț|Ţ/i'=>'t', | |
'/î/i' => 'i', | |
'/â/i' => 'a', | |
'/”|“|…|’|µ|º|’|‘|’|ldquo|rdquo|„|»|–/i' => '-', | |
'/[^[:alnum:]]/'=>' ', | |
'/[^\w\s]/' => ' ', | |
'/\\s+/' => '-', | |
'/\b([a-z]{1,3})\b/i'=>'', | |
'/\-+/' => '-' | |
); | |
$slug = preg_replace(array_keys($map),array_values($map),$slug); | |
return $slug; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment