Skip to content

Instantly share code, notes, and snippets.

@mrcodefinger
Last active February 15, 2023 08:20
Show Gist options
  • Save mrcodefinger/885b23b23eb48cd4d3c0a48637804447 to your computer and use it in GitHub Desktop.
Save mrcodefinger/885b23b23eb48cd4d3c0a48637804447 to your computer and use it in GitHub Desktop.
Free string from German umlauts
function cleanString($string) {
$string = str_replace([' ', 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', 'ß'], [' ', 'Ae', 'ae', 'Oe', 'oe', 'Ue', 'ue', 'ss'], $string);
$string = preg_replace('/[^A-Za-z0-9\-]/', '-', $string);
return preg_replace('/-+/', '-', $string);
}
echo cleanString('In Köln trinkt man Kölsch und in Düsseldorf trinkt man Alt.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment