I have a string and within that string are some links of the format
<a href="...some url...">Text</a>
I want to replace that entire section with a different piece of markup
The problem is that while I can get the overall structure of the markup to be replaced; and also the URL, it’s not so easy for me to get the “Text”. If I knew the entire link then I might do something like.
‘str_replace( $each_link , $my_new_markup , $the_original_string );’
and iterate through each link, but I cant because I cant know what $each_link is going to be exactly.
Is there any way to look for something like this? I am thinking it must have something to do with REGEX but I am totally hopeless at it, and I don’t even know if that’s the right place to start.
<a href="...some url..."> [WILDCARD of some kind] </a>
You could look at a class like this, Simple HTML DOM Parser that you can use to cycle through elements searching for a specific inner html or other attribute and then change it.
Code looking something like this