Hi!
My head is about to explode, so before it does I'll try my luck here. I need to replace this:
Blah yadah <a href="http://www.foo.com/">foo.com</a> blah blah, yadah yadah <a href="http://www.foo.net/" target="_blank">foo.net</a>.
with this:
Blah yadah foo.com ( http://www.foo.com/ ) blah blah, yadah yadah foo.net ( http://www.foo.net/ ).
Yes, I have read http://www.phpbuilder.com/columns/dario19990616.php3 but still can't make it work...
Suggestions, anyone?
Hi,
try this:
$string = 'Blah yadah <a href="http://www.foo.com/">foo.com</a> blah blah, yadah yadah <a href="http://www.foo.net/" target="_blank">foo.net</a>.'; $string = preg_replace("/<a href=\"' [\"' ]+(.?)>(.?)<\/a>/", "\3 (\1)", $string);
echo $string;
firemouse2001
Cheers!
And this seems to work too:
$string = preg_replace("'<a(.)href=\"([\"])\"([>])>(.)</a>'siU", "\4 ( \2 )", $string);