【问题标题】:PHP Remove " from stringPHP 从字符串中删除 "
【发布时间】:2014-04-30 13:04:42
【问题描述】:

我有一个从数据库中获取文本的 PHP 脚本,我想做的是:

如果数据库中的文本如下所示:

[url="something"]Some text[/url]

我希望它看起来像这样:

[url=something]Some text[/url]

我希望你能帮助我。 谢谢

【问题讨论】:

  • 你有没有尝试过?
  • 如果您想更改数据库中的文本以删除引用,您应该看一下this answer

标签: php string replace


【解决方案1】:

你应该使用str_replace:

$str = str_replace('"','',$str);

【讨论】:

    【解决方案2】:
    $text = '[url="something"]Some text[/url]';
    echo $text = preg_replace('#\[url="(.*?)"\]#i','[url=$1]', $text);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-19
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-02
      • 2011-08-29
      • 1970-01-01
      相关资源
      最近更新 更多