Hi all,

I want to replace these charachters:

Æ,Ø,Å,æ,ø,å, with,
AE,OE,AA,ae,oe,aa

I thoght I could use preg_replae this way to accomplish that, but if i write this word in the form: "Bælter" - All that is left to be inserted into the DB is "B" - So I am removing everything from the special charachter away from the string...

This is what i have:

$search = array('/Æ/', '/Ø/', '/Å/', '/æ/', '/ø/', '/å/', '/ /');
$replace = array('AE', 'OE', 'AA', 'ae', 'oe', 'aa', '-');
$vare_gruppe_url = preg_replace($search,$replace,$vare_gruppe_url);

I am using utf-8 - and have read that preg_replace doesnt work too well with 2 byte charachters, i think that was how it was described..

Can someone point out why this is happening and not working?

Basically what i want is this:

"Bælter" should become "Baelter".

Regards, Klemme

According to the third comment here, you should use the 'u' modifier.

Right, How do I implement the 'U' modifier in the pattern, have you any experience with that?

I have tried it different ways, with no succes so far :-/

$search = array('/Æ/', '/Ø/', '/Å/', '/æ/', '/ø/', '/å/', '/ /');
$replace = array('AE', 'OE', 'AA', 'ae', 'oe', 'aa', '-');
$vare_gruppe_url = preg_replace($search,$replace,$vare_gruppe_url);
$search = array('/Æ/u', '/Ø/u', '/Å/u', '/æ/u', '/ø/u', '/å/u', '/ /');
$search = array('/Æ/u', '/Ø/u', '/Å/u', '/æ/u', '/ø/u', '/å/u', '/ /');
$replace = array('AE', 'OE', 'AA', 'ae', 'oe', 'aa', '-');
$vare_gruppe_url = preg_replace($search,$replace,$vare_gruppe_url);

It should be called preg_remove..

I am left with only B if $vare_gruppe_url = "Bælter"..

Any help is appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.