How can I remove slashes from strings?
You can do a number of things here, but the two approaches I would choose from are:
Use str_replace()
:
$string = "people are using Iphone/'s instead of Android phone/'s";
$result = str_replace('/','',$string);
echo $result;
// Output: people are using Iphone's instead of Android phone's
If the slashes are backward slashes (as they probably are), you can use stripslashes()
:
$string = "people are using Iphone\\'s instead of Android phone\\'s";
$result = stripslashes($string);
echo $result;
// Output: people are using Iphone's instead of Android phone's
backslashes need escaping
$newstr = "<h1>Hello \ fred</h1>";
echo str_replace('\\','',$newstr);
If it is a quoted string. Use stripslashes