php - 删除字符串 php 中的“»”字符
问题描述
我知道我的问题似乎重复但在这里搜索了许多解决方案后,它并没有解决我的问题。
我只想替换或删除这个字符"»"。
我试过了:
$string = "Link »";
str_replace('\u00bb', '', $string); >> not work
preg_replace('/[\x00-\x1F\x7F]/u', '', $string); >> not work
filter_var($string, FILTER_SANITIZE_STRING); >> not work
但不起作用!
任何人都可以帮助我吗?谢谢!
解决方案
str_replace
删除用于 PHP的字符串的字符非常简单:
$str = 'some random » that exists here or » there';
echo str_replace('»', '', $str); // some random that exists here or there
为str_replace
您添加要替换的字符,然后添加需要替换的字符,最后添加要修改的字符串。
推荐阅读
- python - 如何创建基于资源的策略?
- excel - 在字符串 VBA 中搜索数字
- azure - 互联网出口的 Kubernetes 网络策略
- node.js - Mongoose find() 并追加到数组
- google-cloud-platform - GCloud 计算实例停止但未停止
- ios - iOS 13 UIViewController 模态演示阴影
- kubernetes-helm - 如何将 istio 注入到使用 helm 部署的部署中
- python - os.path.dirname 和 os.path.join
- angular - 如何设置圆环图的边框宽度
- java - Adempiere 隐藏/显示字段基于使用显示逻辑在客户端窗口中选中或未选中的刻度线