使用PHP删除特殊字符

时间:2011-09-19 12:41:02

标签: php replace special-characters

  

可能重复:
  How to replace Microsoft-encoded quotes in PHP

我的字符串是

iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”

现在我要替换" ’ " by " ' " and " “ " by ' " '

5 个答案:

答案 0 :(得分:1)

echo str_replace(array('’', '“', '”'), array("'", '"', '"'), 'iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”');

See the results of execution on ideone

答案 1 :(得分:1)

$text = "iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”"
$search = array("’", "“");
$replace = array("'", '"');
$new_text = str_replace($search,$replace,$text);

答案 2 :(得分:0)

尝试str_replace功能。

答案 3 :(得分:0)

您可以使用str_replace

 $string = str_replace(array("’",  "“"), array("'", '"'), $string);

答案 4 :(得分:0)

您可以创建要删除的字符数组,并使用str_replace替换其他内容。

ex: $remove = array(',','"',"'",'by','and son on..');
$str = iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”;
$return = str_replace($remove,' ',$str);

感谢..