Php adds a keyword connection to the article. how does one control the number of links automatically added to the article content? What should I do?
Source: Internet
Author: User
Php adds a keyword connection to the article. how does one control the number of links automatically added to the article content? I have now implemented the php output of the specified html keyword link to the specified URL, but one problem is that all the keywords in this article will be linked, I want to control the number of times it links or just let it link the first keyword in the article. how can I implement php to add a keyword connection to the article, how does one control the number of links to automatically add links to the article content?
I have now implemented the php output of the specified html keyword link to the specified URL, but one problem is that all the keywords in this article will be linked, I want to control the number of times it links, or just let it link the first keyword in the article. how can I implement this? The code for automatically linking implemented keywords is as follows:
Function keylink ($ cont ){
$ Keys = array (
Array ('keyword 1', 'http: // link 1 ')
);
Foreach ($ keys as $ nkeys ){
$ Cont = preg_replace ("/($ nkeys [0])/iU", "$ nkeys [0]", $ cont );
}
Return $ cont;
}
Php !!!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service