开发者

replace special characters by its phoenetic similar character (in php - utf8)

you know that there are many characters like è or é. There are many more, like ö,ä,ì,á,ù,...

i want to replace those characters with its "phoenetic partner"-chara开发者_如何转开发cter, but i don't want to do it for each single character like

str_replace(array("á", "à", "é", "è", ...), array("a", "a", "e", "e", ...), &$input);

is there any common way to do something like:

str_replace_phoenetical(&$input)
  • has anybody still wirtten a script which covers all cases?
  • is there a way to automaticly detect those characters and just remove the ` or '?

thanks so far

UPDATE:

does anyone reccomands this one (found on php.net)?


You can transliterate them with iconv().

$str = 'áàéè';

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

var_dump($transliterated); // string(4) "aaee"

Ideone.


unidecode

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜