取代& nbsp;隐藏在文字中的字符 [英] replace   characters that are hidden in text

查看:172
本文介绍了取代& nbsp;隐藏在文字中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在下面的文本中删除 (隐藏的)和空格,但是

How to remove   (that are hidden) and SPACES in below text but

  • 保留UNICODE字符
  • 按住<br>标记

我测试过:

  • 我用过trim($string) =>没用
  • 我用过str_replace('&nbsp;', '', $string) =>没用
  • 我使用了一些正则表达式=>没用

  • i used trim($string) => NOT WORKED
  • i used str_replace('&nbsp;', '', $string) => NOT WORKED
  • i used some regex => NOT WORKED

            <br>تاريخ ورود: یکشنبه ۲۳ بهمن ماه ۱۳۹۰

更新: 谢谢

推荐答案

此解决方案可以正常工作,我已经对其进行了测试:

This solution will work, I tested it:

$string = htmlentities($content, null, 'utf-8');
$content = str_replace("&nbsp;", "", $string);
$content = html_entity_decode($content);

这篇关于取代&amp; nbsp;隐藏在文字中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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