替换字符串中一系列字符的最快方法 [英] Quickest way to replace a series of characters in a string

查看:38
本文介绍了替换字符串中一系列字符的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道用空替换字符串中某些字符的最快方法是什么.我现在有以下内容:

I'm wondering what is the quickest way to replace certain characters in a string with nothing. I now have the following:

$omschrijving = str_replace(")", "", str_replace("(", "", $line)));

有没有更好的方法来做到这一点?这只是替换了 "("")",但是如果我想用更多字符做同样的事情怎么办.仍在学习 preg_ 方法,但目前仍然有点令人兴奋.

Is there a better way to do this? This is only replacing the "(" and ")", but what if I want to do the same with more characters. Still learning the preg_ methods but it's still a bit of mind blowing at the moment.

推荐答案

给你:

str_replace(array('a', 'b', 'c', 'd'), '', $sString);

来自手册:

替换找到的搜索值的替换值.一个数组可用于指定多个替换.

The replacement value that replaces found search values. An array may be used to designate multiple replacements.

这篇关于替换字符串中一系列字符的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆