Say you have a dynamic string gotten from an ajax call. As example this is one response:
$string = '<div>
<a href="http://somelink" class="possible-class">text</a>
<a href="http://anotherlink">other text</a>
</div>';
How can you modify all the href urls in the string to be the result of another method, such as this example method:
function modify_href( $href ) {
return $href . '/modified';
}
so then the resulting string is:
$string = '<div>
<a href="http://somelink/modified" class="possible-class">text</a>
<a href="http://anotherlink/modified">other text</a>
</div>';