I have a string like:
$description = '
<a href="http://www.replace.com/1st-link/">1st link in string</a>,
<a href="http://www.ignore.com/">2nd link in string</a>, some other text in string,
<a href="http://www.replace.com/3rd-link/">3rd link in string</a>.
';
I need to use preg_replace to append a query parameter of "?id=awesome" to any urls in the $description string from "replace.com" (ignoring all other links, i.e. "ignore.com").
Thanks in advance for any help!
Ok, simple enough, here you go:
Hope that's it, $content will have the string witht he added paramters to the replace.com domain :)
I would strongly advise using a DOM parser instead of a regex. For instance: