Replace é with e in PHP

Hey, this is my first post on stackoverflow.

I am trying to replace é with e and other similar special characters. I tried str_replace () and converted it from UTF-8 to ASCII, but nothing works. When I convert it from UTF-8 to anything, it just drops. When I use str_replace (), it never catches it, and é is still there.

I have a feeling that something is wrong inside the server, because my friend tried str_replace () on his server and it worked fine.

Thank,

Jason Tolhurst

+3
source share
3 answers
$string = iconv('utf-8','ASCII//IGNORE//TRANSLIT',$string);
+7
source

htmlentities() é é, , .

function RemoveAccents($string) {
    // From http://theserverpages.com/php/manual/en/function.str-replace.php
    $string = htmlentities($string);
    return preg_replace("/&([a-z])[a-z]+;/i", "$1", $string);
}
+4

. php strtr()

The examples on this page are specific to your situation.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1773659/


All Articles