duanchijie2323 2012-06-21 17:40
浏览 84

在php中替换multibyte utf8字符

I am trying to preg_replace the multibytecharacter for euro in UTF (shown as ⬠in my html) to a "$" and the * for an "@"

$orig = "2 **** reviews  ⬠19,99 price";
$orig = mb_ereg_replace(mb_convert_encoding('€', 'UTF-8', 'HTML-ENTITIES'), "$", $orig);
$orig = preg_replace("/[\$\;\?\!\{\}\(\)\[\]\/\*\>\<]/", "@", $orig);
$a = htmlentities($orig);
$b = html_entity_decode($a);

The "*" are being replaced but not the "â¬" .......

Also tried to replace it with

$orig = preg_replace("/[\xe2\x82\xac]/", "$", $orig);

Doesn't convert either....

Another plan which didnt work:

$orig= mb_ereg_replace(mb_convert_encoding('&#x20ac;', 'UTF-8', 'HTML-ENTITIES'), "$", $orig);

Brrr someone knows how to get rid of this utf8 euro character:

echo html_entity_decode('&euro;');

(driving me nuts)

  • 写回答

3条回答 默认 最新

  • douyong6585 2012-06-21 18:23
    关注

    Pasting my comment here as an answer so you can mark it!

    Wouldn't

    str_replace(html_entity_decode('&euro;'), '$', $source)
    

    work?

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)