Skip to content

Instantly share code, notes, and snippets.

@nonsintetic
Created November 27, 2015 13:19
Show Gist options
  • Save nonsintetic/9144e9a43d50a1ce90d6 to your computer and use it in GitHub Desktop.
Save nonsintetic/9144e9a43d50a1ce90d6 to your computer and use it in GitHub Desktop.
create url slugs from romanian phrases (diacritics, punctuation and link words handling)
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