如何在php字符串中将特殊字符(')替换为空格[复制]

This question already has an answer here:

I want to replace special character single quotes(') with space . In Java it is easy but i dont know how to do this in php.

</div>
<?php $data = str_replace("'", " ", string);
      echo $data;
?>

You can use str_replace() string function in php.

Example : echo str_replace(" ' "," ","India' ");

Explanation : Here, in str_replace() function first argument you need to pass string which you want to replace. For second argument you need to pass string you want to replace with existing. And for third and last argument you need to pass your original string in which you need replace.

to remove just single quote :

$FileName = str_replace("'", " ", string);

to remove other characters as well, use array :

$remove[] = "'";
$remove[] = '"';
$remove[] = "-"; // just as another example

$FileName = str_replace( $remove, " ", string);