我正在尝试做一些 PHP 编程概念,但我不知道某些内置函数。所以我的疑问是:
在 PHP 中,如何去除字符串中的斜线? PHP 中是否有任何可用的函数??
例如
$string="people are using Iphone/'s instead of Android phone/'s";
最佳答案
你可以在这里做很多事情,但我会选择的两种方法是:
使用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
如果斜杠是反斜杠(可能是),您可以使用 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
关于php - 如何从字符串中删除斜杠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8266476/