castor
castor

Reputation: 61

Convert Special Characters (other language) to English in PHP

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

Upvotes: 6

Views: 14938

Answers (4)

Tanuljjatszva
Tanuljjatszva

Reputation: 51

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

Upvotes: 5

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.

Upvotes: 0

Matthew
Matthew

Reputation: 48284

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).

Upvotes: 0

danp
danp

Reputation: 15241

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

Upvotes: 7

Related Questions