我是一个相对较新的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个字的出现,那么代码不要通过错误也很重要.
我将如何做到这一点,任何想法将不胜感激.