Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to do some PHP programming concepts and I am not aware of some in-build functions. So my doubt is:

In PHP, how to remove slashes from strings? Is there any function available in PHP for this??

e.g.

$string="people are using Iphone/'s instead of Android phone/'s";
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
671 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...