$string1 = preg_replace('/[^A-Za-z0-9äöü!&_=\+-]/', ' ', $string4);
This Regex shouldn't replace the chars äöü. In Ruby it worked as expected. But in PHP it replaces also the ä ö and ü.
Can someone give me a hint how to fix it?
Set the u
pattern modifier (to tell php to treat the regex as a UTF-8 string).
'/[^A-Za-z0-9äöü!&_=\+-]/u'