PHP-将ΓÇô转换为破折号 [英] PHP - Convert ΓÇô to dash

查看:138
本文介绍了PHP-将ΓÇô转换为破折号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP脚本中发现了一些特殊字符。其中之一是ΓÇô。它实际上是破折号-的特殊字符。我应该如何将其转换为破折号以便处理字符串?

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?

推荐答案

我找到了答案!它的灵感来自此答案

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);

立即替换字符将无效。绝对需要 html_entity_decode

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

这篇关于PHP-将ΓÇô转换为破折号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆