How can I remove two character? Here's my code:
如何删除两个字符?这是我的代码:
str_replace('\'| ', '',"remove ' and spaces");
I'm trying to use the | but it's not working
我正在尝试使用|但它不起作用
1 个解决方案
#1
2
Looking at \'|
, it seems you want to remove either '
or a space. str_replace
(that does not allow regex as its needle argument) accepts an array of search strings as the first argument:
看着''|,似乎你想要删除'或空格。 str_replace(不允许正则表达式作为其needle参数)接受一个搜索字符串数组作为第一个参数:
search
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.搜索要搜索的值,也称为针。阵列可用于指定多个针。
So, use
$s = str_replace(array("'",' '), "", "remove ' and spaces");
// => removeandspaces
See demo
#1
2
Looking at \'|
, it seems you want to remove either '
or a space. str_replace
(that does not allow regex as its needle argument) accepts an array of search strings as the first argument:
看着''|,似乎你想要删除'或空格。 str_replace(不允许正则表达式作为其needle参数)接受一个搜索字符串数组作为第一个参数:
search
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.搜索要搜索的值,也称为针。阵列可用于指定多个针。
So, use
$s = str_replace(array("'",' '), "", "remove ' and spaces");
// => removeandspaces
See demo