views:

302

answers:

4

Is there a function that coverts special characters to their english equivalents. For Eg. Convert é to e. Etc...

+2  A: 

The function you are after is iconv() - from the user notes, this seems to be what you want to do: characters transliteration

danp
When I used iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $str); to convert João, it returened JooI would like it to return Joao...
castor
Make sure the string is truly UTF-8. Encoding could be why it's not working as expected.
konforce
Isn't there a script that changes everything (all type of formattings) to plain english. I can't get the code to work :(
castor
`echo iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', "Jo\xc3\xa3o");` Note that I've hard coded the 'ã' as UTF-8 (0xc3a3) to ensure that the encoding is correct.
konforce
A: 

If you don't like danp's solution (iconv), you could use strtr with a list of conversions. This page has a sample script (first Google result).

konforce
A: 

You could make a function holding a array of chars you want exchanged and pass strings through and just change ã to a that way, if iconv() doesn´t work out for you.

Wilhelm Björklund
A: 

You should use this one and it will works:

setlocale(LC_CTYPE, 'nl_BE.utf8');

$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);

I've tested it a lot of accentuated characters

Tanuljjatszva