Created
November 27, 2015 13:19
-
-
Save nonsintetic/9144e9a43d50a1ce90d6 to your computer and use it in GitHub Desktop.
create url slugs from romanian phrases (diacritics, punctuation and link words handling)
This file contains hidden or 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 slugify_romanian($input) { | |
$out = str_replace(array( | |
',', | |
':', | |
'”', | |
'.', | |
'"', | |
"'", | |
'!', | |
'?', | |
'-', | |
),'',$input); | |
$out = preg_replace("#[[:punct:]]#", "", $out); | |
$out = str_replace( | |
array( | |
'Ă', | |
'ă', | |
'Ã', | |
'ã', | |
'Î', | |
'î', | |
'Â', | |
'â', | |
'Ţ', | |
'Ț', | |
'ţ', | |
'ț', | |
'Ş', | |
'ş', | |
'ș', | |
'Ș', | |
'é', | |
' ', | |
), | |
array( | |
'A', | |
'a', | |
'A', | |
'a', | |
'I', | |
'i', | |
'A', | |
'a', | |
'T', | |
'T', | |
't', | |
't', | |
'S', | |
's', | |
's', | |
'S', | |
'e', | |
'-', | |
),$out); | |
$out = str_replace(array( | |
'-si-', | |
'-cu-', | |
'-din-', | |
'-pe-', | |
'-un-', | |
'-sau-', | |
'-de-', | |
'-prin-', | |
'-in-' | |
),'_',$out); | |
$out = str_replace('--','-',$out); | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment