I have the following which replace all of å, ø, æ .... etc to just _.
$string = strtolower($string);
$regexp = '/( |å|ø|æ|Å|Ø|Æ|Ã¥|ø|æ|Ã…|Ø|Æ)/iU';
$replace_char = '_';
$data = preg_replace($regexp, $replace_char, $string);
Now I want to change them to according to the followings.
Replace,
space to _
å, Å, Ã¥ and Ã… to a,
ø, Ø, à and ظ to o,
æ, Æ, æ and Æ to e.
Can I use str_replace with array to do it? If yes, how to?
Or do I have to repeat the same regex three times?
Could anyone tell me better way to write the code?
--EDIT--
Pleas ignore the encoding at the moment. I am NOT asking advices about encoding now.
I asked the encoding problem here. http://stackoverflow.com/questions/1989806/norwegian-characters-problem