I have a string, it contains umlauts and other chars I want to replace, right now my code looks like that:
$string = preg_replace('/( +)|([()])|(\/)/', '_', $string);
$string = preg_replace('/_{1,}/', '_', $string);
$string = preg_replace('/_$/', '', $string);
$string = str_replace('ö', 'oe', $string);
$string = str_replace('ü', 'oe', $string);
$string = str_replace('ä', 'oe', $string);
$string = str_replace('Ä', 'Ae', $string);
$string = str_replace('Ü', 'Ue', $string);
$string = str_replace('Ö', 'Oe', $string);
Is there a shorter way of doing that?
Thanks 🙂
You could use
str_replacewith an array: