PHP: regular expression to remove `â` or `â€`?

筅森魡賤 提交于 2019-12-23 15:48:25

问题


I use this regular expression to remove all the punctuation marks from a string input,

$pg_url = preg_replace("/\W+/", " ", $pg_url); 

but there are some kind of symbols or special characters I can't remove them, such as

when I pass this into my db injection, it will either turns into â or â€

How can I get rid of these strange stuff?

Thanks.


回答1:


Those characters are encoded in Unicode, specifically UTF-8.

You may want to consider using the iconv family of functions to convert them into some other encoding (e.g. plain ASCII first).



来源:https://stackoverflow.com/questions/4761586/php-regular-expression-to-remove-%c3%a2-or-%c3%a2%e2%82%ac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!