PHP - Convert ΓÇô to dash

2019-09-21 21:32发布

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条回答
对你真心纯属浪费
2楼-- · 2019-09-21 22:20

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.

查看更多
登录 后发表回答