douwei7471
douwei7471
2015-01-21 09:26

最佳方式:str_replace,嵌套替换[复制]

已采纳

This question already has an answer here:

I have a question, what is the most optimal way for replace the strings for example, I want to replace and with ''. I have 2 options :

  1. Replaces nested:

    SELECT REPLACE(REPLACE(m3.old_message,' ',''),' ','')

  2. Preg replace:

    if ($aField== 'user') { $sValue = preg_replace... }

Thx in advance.

</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • drd2551 drd2551 6年前

    In PHP you can do:

    $string = preg_replace('/\R/', '.', $string);
    

    Where \R stands for any line break, or or .

    点赞 评论 复制链接分享