PHP - Convert ΓÇô to dash

孤街醉人 提交于 2019-12-27 00:56:30

问题


I found some special characters in my PHP script. One of them is ΓÇô. It's actually a special character of a dash -. How should I convert it back to dash so I can process the string?


回答1:


I found the answer! It's inspired by this answer

$title = "Hunting, Tactical & Outdoor Optics eCommerce Store ΓÇô $595,000 ΓÇö SOLD";
$title = str_replace(html_entity_decode('–', ENT_COMPAT, 'UTF-8'), '-', $title);
$title = str_replace(html_entity_decode('—', ENT_COMPAT, 'UTF-8'), '-', $title);

Replacing the character right away won't work. html_entity_decode is definitely needed.



来源:https://stackoverflow.com/questions/44357332/php-convert-%ce%93%c3%87%c3%b4-to-dash

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