首页 > 解决方案 > 删除字符串 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

但不起作用!

任何人都可以帮助我吗?谢谢!

标签: phpstringreplace

解决方案


str_replace删除用于 PHP的字符串的字符非常简单:

$str = 'some random » that exists here or » there';
echo str_replace('»', '', $str); // some random that exists here or there

str_replace您添加要替换的字符,然后添加需要替换的字符,最后添加要修改的字符串。


推荐阅读