php function to remove accented (unallowable) url characters
by Prakash[ Edit ] 2013-07-01 16:43:27
The following is a php function which removes the non allowable characters in a string.
//function to clean accentented characters to get clean string
function replaceAccentedCharacters($input)
{
$accent='ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËéèêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ:';
$noaccent='AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn-';
$cleaned = strtr($input, $accent, $noaccent);
return $cleaned;
}
//function end
Use it as follows :
$string = 'Åàgra';
echo replaceAccentedCharacters($string); //prints 'Aagra'