I have a bunch of text with html in it. Basically what I want to do is for all links found in this text I want to add a rel=”noindex” to every link found only if the title attribute is no present.
For example if a link looks like this:
<a href="test.html">test</a>
I want it to look like:
<a rel="nofollow" href="test.html">test</a>
But if the link looks like this:
<a title="test title" href="test.html">test</a>
I dont want to add the rel=”nofollow” attribute to that. How can I do that in php?
EDIT:
Im sorry I didnt mention this but I am using PHP4. Yes I know but Im stuck with PHP4.
First use preg match to get if title is added.