Home  >  Article  >  Backend Development  >  PHP 如何实现数据库字符串批量替换?

PHP 如何实现数据库字符串批量替换?

WBOY
WBOYOriginal
2016-06-06 20:21:411168browse

我想问有没有php函数,可以获取相应的字符串?
比如:
$db = "fcfce设计的方式爱人决定覅飞retete机的是爱人士大夫精神reererer43434343的"
然后在$db 里查询关于‘爱人’两个词,
得出结果是:爱人,爱人。

如何做到呢?

回复内容:

我想问有没有php函数,可以获取相应的字符串?
比如:
$db = "fcfce设计的方式爱人决定覅飞retete机的是爱人士大夫精神reererer43434343的"
然后在$db 里查询关于‘爱人’两个词,
得出结果是:爱人,爱人。

如何做到呢?

楼主的意思应该是查询一个目标字符串中有多少个子字符串,然后拼接成一个新的字符串的意思。

我觉得PHP里面现在应该没有这样的方法,但是可以将问题分部解决
1:先查询出有多少个 可以使用 mb_substr_count,查询出有多少个
2:拼接成新的字符串返回 拼接就很容易了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn