Friday, 23 August 2013

How to replace a href links in php

How to replace a href links in php

I need to replace all <a> hrefs with some text in a php file. I have used
preg_replace('#\s?<a.*/a>#', 'text', $string);
But this replaces all links with the same text. I need different texts for
each links. How to achieve this. Also is it possible to get the href link
fully, means if i have a file containing the link <a
href="www.google.com">Google</a>, how can i extract the string '<a
href="www.google.com">Google</a>'.
Please help me.

No comments:

Post a Comment