Link to home
Start Free TrialLog in
Avatar of Fernanditos
Fernanditos

asked on

PHP Function to Replace spacial character accents

Hi,

I need help building a function that replace all special accent characters by the non-accent character.

$string = "La più bellä du Du côté"

The result should be:

$string = "La piu bella du Du cote"

Can some expert please help me with this function that I'd call normalize($string)

Thank you in advance.
Avatar of Prophion
Prophion

You could use the str_replace function (http://www.php.net/manual/de/function.str-replace.php) to write a function to replace such characters in your string.
Avatar of Loganathan Natarajan
did you try with normalizer_normalize? http://php.net/manual/en/normalizer.normalize.php
ASKER CERTIFIED SOLUTION
Avatar of edster9999
edster9999
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use preg_replace like so
$string = "La più bellä du Du côté";
$patterns = array('/ù/','/ä/','/ô/','/é/');
$replacement = array('u','a','o','e');

echo preg_replace($patterns, $replacement, $string);

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial