OiO.lk Blog PHP Why does PHP preg_replace() not propery replace “µ” in string?
PHP

Why does PHP preg_replace() not propery replace “µ” in string?


I got this string:

"Grünkohl (gegart) [vom Bauern, -50% gewaschen([{vBü,_-4%?+#*^°\ß´`&§"!<>|'~.:,;µ{}/$²³}])"

I want to have all characters except some allowed ones replaced by "-".

This is my function call:

preg_replace('/[^a-z0-9äöü°!"²§³\\$&\\(\\[\\)\\]=ß´\\+\\*~\'\\-_\\.:\\,;<>@€]/i', '-', $string);

And this is the string I get:

"Grünkohl-(gegart)-[vom-Bauern,--50--gewaschen([-vBü,_-4--+-*-°-ß´-&§"!<>-'~.:,;�----$²³-])"

Why is the "µ" not propery replaced? (it turned to "�-")



You need to sign in to view this answers

Exit mobile version