php - 如何从字符串中删除斜杠?

标签 php

我正在尝试做一些 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/

相关文章:

php - 西莱克斯 2 : RegEx in routing

php - 使用 api 调用更新 laravel 中的值

php - 在 php 中使用自动加载并搜索类文件会影响性能吗?

php - 如何使用 php + css 更改事件菜单的样式

php - mysql中如何用一个文本字段在多个字段中进行搜索?

php - 在我的案例中,如何在 mysql 查询中使用 case 语句?

php - 查询进入无限循环

php - Wordpress Memberships - 获取计划的所有事件成员,这些成员的特定元键具有非空值。还检索额外的元数据

php - 如何重写 WordPress 中的 get_post 函数?

php - 使用 PHP 记录 Google Analytics?可能的?