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.
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.
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.
did you try with normalizer_normalize? http://php.net/manual/en/normalizer.normalize.php
also another method to try, http://www.ficgs.com/How-to-remove-accents-in-PHP-f3057.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.