Re: replace accents

From: Date: Tue, 14 Sep 2004 20:35:47 +0000
Subject: Re: replace accents
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-196660@lists.php.net to get a copy of this message
At 17:51 14-09-2004, Diana Castillo wrote:
Anyone know of any function to replace letters with accents with just the regular letter, for instance replace á with a, ç with c, ñ with n ?
How about this ??? This is the one I made for this purpose function stripAccents($string) { $returnString = strtr($string,
      'àáâãäçèéêëìíîïñòóôõöšùúûüýÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕ֊ÙÚÛÜÝ', 'aaaaaceeeeiiiinooooosuuuuyAAAAACEEEEIIIINOOOOOSUUUUY');
$returnString = str_replace('æ','ae',str_replace('Æ','AE',$returnString)); $returnString = str_replace('ø','o',str_replace('Ø','O',$returnString)); $returnString = str_replace('å','a',str_replace('Å','å',$returnString)); $returnString = str_replace('ß','ss',$returnString); $returnString = str_replace(''','',str_replace("'",'',$returnString)); $returnString = str_replace('"','',str_replace('"','',$returnString)); return $returnString; } obviously there's room for improvement, but it's from a QAD script (not production) -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/

« previous php.general (#196660) next »