从字符串php中删除特定字符列表

时间:2015-06-26 10:52:26

标签: php arrays string

$string = "' ! ; • ,\ KarSho: ; • ;}";

在这里,我想删除以下字符,

$remove = array("'","!",";","•",",","\","}","{","[","]");

这也是输入。我想要来自 $ string 的数组字符。最后我想要字符串,

  

KarSho:

2 个答案:

答案 0 :(得分:0)

使用以下代码:

$remove = array("'","!",";","•",",","\\","}","{","[","]"," ");
$replace = array("","","","","","","","","","","");
$string = "' ! ; • ,\ KarSho: ; • ;}";
echo str_replace($remove,$replace,$string);

您需要在\

中再添加一个\

答案 1 :(得分:0)

您可以使用此代码

j