php 第二次出现位置,php – Preg Replace – 替换匹配的第二次出现

我是一个相对较新的PHP,并希望有人可以帮助我替换正则表达式,或者可能匹配替换我不完全确定.

我想自动加粗(第二次出现一场比赛),然后第四次出现一场比赛斜体,然后第7次出现一场比赛下划线.

这基本上是针对内容中的SEO目的.

我做了一些替换:并且认为这应该做的伎俩?

preg_replace( pattern, replacement, subject [, limit ])

我已经知道了我想用的词

'pattern' is also a word that is already defined like [word].

`replacement` 'This is a variable I am getting from a mysql db.

'subject' - The subject is text from a db.

让我说我有这样的内容:这或多或少解释了我想做什么.

This is an example of the text that I want to replace. In this text I want to make the second occurance of the word example < bold. Then I want to skip the next time example occurs in the text, and make the 4th time the word example appears in italic. Then I want to skip the 5th time the word example appears in the text, as well as the 6th time and lastly wants to make the 7th time 07000 appears in the text underline it. In this example I have used a hyperlink as the underline example as I do not see an underline function in the text editor. The word example may appear more times in the text, but my only requerement is to underline once, make bold once and make italic once. I may later descide to do some quotes on the word “example” as well but it is not yet priority.

如果没有至少7个字的出现,那么代码不要通过错误也很重要.

我将如何做到这一点,任何想法将不胜感激.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值