I am using PHP. I have some articles stored in MySQL and they all have some style (like with some css or tags). Now I have to add some links to some text randomly and automatically. This means I have to add links to the text and make sure the links do not break the style.
I think the most difficult part is how to add links but not to break the style. Are there any rules or example I can follow to make this in PHP?
Any help and advices is great appreciated~
Updated:
Maybe this question is how to choose the "right text" to add links. If the text is already in a link, it is not suitable. So what should I do about this?
For example:
<div>This is an article with some <a href="http://originallinks.com">original links</a></div>
I need to choose some text to add links. The text is chosen randomly by program. If the text is "article":
<div>This is an <a href="http://anotherlink.com">article</a> with some <a htef="originallinks.com">original links</a></div>
This will be OK, but if the text is "original":
<div>This is an article with some <a htef="originallinks.com"><a href="http://anotherlink.com">original</a> links</a></div>
This would be bad cause the link was added into another link.
So my problem is how to choose the right text to add(this process is randomly and automatically). What should I take into consideration to make this?