what ASCII characters are these?

前端 未结 5 838
不思量自难忘°
不思量自难忘° 2021-01-06 19:02

I have two characters that I need to do a search and replace on in a php-string.

Somehow these are differ

5条回答
  •  被撕碎了的回忆
    2021-01-06 19:46

    Why not just use str_replace ?

    $new_str = str_replace(array('’', '“'), '', $str);
    

    Of course, this requires your PHP scripts to be saved as UTF-8.


    And if this doesn't work because those characters cannot be properly written using UTF-8, you'll have to fallback to using their hexadecimal representations.

    For example :

    $new_str = str_replace(array('\xC2\x91', '\xC2\x93'), '', $str);
    

    (Not sure the hexadecimal values I used are really those of your two special quotes, though)

提交回复
热议问题