Convert Foreign Characters in PHP
I couldn't find a built in function to convert foreign characters, so I constructed the following, which seems to be working well. However, I'm not sure how it will hold up on other machines with other charsets... But hopefully it works for you and saves some time.
function convertForeignCharacters($string) {
$find = "àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸåÅøØ" ;
$replace = "aeiouAEIOUaeiouyAEIOUYaeiouAEIOUanoANOaeiouyAEIOUYaAoO" ;
$output = strtr($string,$find,$replace);
return $output;
}
This post was published on Wednesday, November 25th, 2009 by Robert James Reese in PHP. Before using any of the code or other content in this post, you must read and agree to our Terms & Conditions.
0 Comments
Be the first to leave a comment.
Leave a Comment