Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除“»&引用;字符串php中的char_Php_String_Replace - Fatal编程技术网

删除“»&引用;字符串php中的char

删除“»&引用;字符串php中的char,php,string,replace,Php,String,Replace,我知道我的问题似乎是重复的,但在这里搜索了许多解决方案后,我的问题没有得到解决 我只想替换或删除此字符“»” 我试过: $string = "Link »"; str_replace('\u00bb', '', $string); >> not work preg_replace('/[\x00-\x1F\x7F]/u', '', $string); >> not work filter_var($string, FILTER_SANITIZE_STRING); >

我知道我的问题似乎是重复的,但在这里搜索了许多解决方案后,我的问题没有得到解决

我只想替换或删除此字符“»”

我试过:

$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
但不管用

有人能帮我吗?谢谢

试试这个:

 $value = str_replace('>>','',$string);

删除字符串中的字符非常简单。PHP使用
str\u replace

$str = 'some random » that exists here or » there';
echo str_replace('»', '', $str); // some random that exists here or there
对于
str\u replace
添加要替换的字符,然后添加需要替换的字符,最后添加要修改的字符串。

  • '\u00bb'
    不等于
    >
  • C转义符在单引号中不起作用
  • 对于PHP字符串,它应该是
    “\u{00bb}”
  • 您的charclass
    [\x00-\x1F\x7F]
    仅用于ASCII控制字符,而不用于此unicode码点
  • 对于正则表达式和这个特定字符,可以使用
    \x{00bb}

和str\u replace('»,'',''$string)不起作用???
preg\u replace('/[^a-zA-Z0-9%\[\]\.\(\)%&-]/s','',''$string)
字符始终是最后一个字符,您可以使用修剪或子字符串函数来实现此操作或
preg_replace('/[^A-Za-z0-9\-]/','',$string)他说的是字符
>
,不是两次
哦,天哪,这是工作。。我想得太多了,这使我不能简单地思考。谢谢兄弟。