Replacement of accented characters

0

The preg_replace function is not behaving the way I did. When I run the code $string = preg_replace("/[ÁÀÂÃÄáàâãä]/", "a", $string); what I get returned is a string full of "a's." If the string has "ÀÀ á â Í Í ì" "a a a a a a a a a a a, the preg_replace response is" aaaaaaaaaaaaaaaaaaaaaaaai ". Can you explain why this happens? And what is the best way to do this?

    
asked by anonymous 02.06.2016 / 15:14

1 answer

0

You can use incov to do this:

preg_replace('/[^a-z]/i', '', iconv("UTF-8", "US-ASCII//TRANSLIT", $string))

If I understood your problem well, this should be the resolution.

    
02.06.2016 / 16:06