Php: how to insert random keywords into strings. example: how to insert several keywords randomly in a function in an article (the number of keywords should be controllable)
Insert random keywords to the random position of the article.
For example, the limit is to insert three keywords. The number of keywords inserted in the article is three.
The insert position is also random.
Examples of functions
Reply to discussion (solution)
If the document does not contain html tags, the problem is simple.
However, if the problem exists, the problem becomes very complicated.
What kind of situation do you plan to deal? Let's talk about it!
It is a TXT text without html tags.
$ S = <TXT randomly inserts several keywords in an article (the number of keywords should be controllable) insert random keywords at random positions in the article. For example, the limit is to insert three keywords. The number of keywords inserted in the article is three. The insert position is also random. TXT; $ w = 'keyword, random, insert'; echo foo ($ s, $ w); function foo ($ txt, $ word, $ charset = 'gbk ') {foreach (explode (',', $ word) as $ v) $ tmp [] = iconv ($ charset, 'ucs-2 ', "[{$ v}]"); $ txt = iconv ($ charset, 'ucs-2', $ txt); for ($ I = 0; $ I
Insert several keywords randomly in an article (the number of keywords must be controllable)
Insert random keywords to the random position of the article.
[Random]
For example, the limit is to insert three keywords [insert ]. In the keyword chapter, there are three keywords inserted.
The insert position is also random.
$ S = <TXT randomly inserts several keywords in an article (the number of keywords should be controllable) insert random keywords at random positions in the article. For example, the limit is to insert three keywords. The number of keywords inserted in the article is three. The insert position is also random. TXT; $ w = 'keyword, random, insert'; echo foo ($ s, $ w); function foo ($ txt, $ word, $ charset = 'gbk ') {foreach (explode (',', $ word) as $ v) $ tmp [] = iconv ($ charset, 'ucs-2 ', "[{$ v}]"); $ txt = iconv ($ charset, 'ucs-2', $ txt); for ($ I = 0; $ I
Insert several keywords randomly in an article (the number of keywords must be controllable)
Insert random keywords to the random position of the article.
[Random]
For example, the limit is to insert three keywords [insert ]. In the keyword chapter, there are three keywords inserted.
The insert position is also random.
If there is HTML code, what is a good method?