transform and convert characters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

transform and convert characters

Post by yacahuma »

What can I do to compare Catano with Cataño so that they are the same. I tried different methods to convert the characters but they dont seem to work. For example:

Code: Select all

 
  function translate($string)
    {
        $accented =array('ñ','á','ú','í','é','ó');
        $replace =array('n','a','u','i','e','o');
return str_replace($accented, $replace, $string);        
        
    }        
 
I am using utf-8 in my pages and database

thank you
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: transform and convert characters

Post by Jonah Bron »

Maybe try using ord('ñ') in that array instead?
Post Reply