Let's say I submit a form with the message:
Hi! What's up? <a href="http://test.com">Click here</a> to check out <a href="http://test.com">my</a> website.
How can detect if the string contains <a>
tags with PHP, and then add rel="nofollow"
to it? So it would change to:
Hi! What's up? <a href="http://test.com" rel="nofollow">Click here</a> to check out <a href="http://test.com" rel="nofollow">my</a> website.
A little speculation of how the code would function?
$string = $_POST['message'];
if (*string contains <a> tags*) {
*add rel="nofollow"*
}
There's always the DOMDocument object.