<?php $x = 'รmystr'; print str_replace('ร', 'AE', $x);
This code works very well, I believe that what you are missing is a change in the encoding of your file. Your .php file must be encoded in UTF-8 or UNICODE. This can be done in some (text) editors or IDEs, for example Eclipse, EditPlus, Notepad ++, etc. Even Notepad on windows 7.
When saving, the "Save / Save As" dialog box opens and usually next to the "Save" button there is a drop-down menu / "Encoding" that allows you to choose between ANSI and UTF-8 (and others). A.
On * nix I think most editors have this, just not sure about the places. If after you do this and make money, edit / save using an editor that just executes ANSI, it will overwrite it with an unknown char, etc.
As for why the code below does not work.
return str_replace(chr(195), 'Ae', $string);
This is because unicode char usually contains 2 characters. So what you have above is just the beginning of a unicode char. try the following:
print str_replace(chr(195).chr(134), 'AE', $x);
This should also replace it, and may even be preferable, since you (probably do not) should not change the encoding of the file.
source share