Last active
February 15, 2023 08:20
-
-
Save mrcodefinger/885b23b23eb48cd4d3c0a48637804447 to your computer and use it in GitHub Desktop.
Free string from German umlauts
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 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