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.
Asked
Active
Viewed 219 times
-5

Arsalan Mithani
- 490
- 3
- 11

007_android
- 57
- 1
- 5
-
1Google: `php replace character` And you'll be back here – u_mulder Feb 01 '17 at 12:23
-
i didnt undustood – 007_android Feb 01 '17 at 12:24
3 Answers
1
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.

Viral Patel
- 72
- 6
-
Here if str_replace() find multiple occurrence of your search string then also it will replace with white space. – Viral Patel Feb 01 '17 at 12:34
-
For more details you can review this link http://php.net/manual/en/function.str-replace.php – Viral Patel Feb 01 '17 at 12:54
0
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);

Arsalan Mithani
- 490
- 3
- 11