I have a chunk of HTML in a string. I want to get the LAST a
tag and apply a class. How would you solve this in PHP?
You could be inelegant, and get the count of the “a” array, and then increase a counter until the count and counter match, then apply tag.
indeed. This is my current approach but the class is being applied to all $links gist.github.com/2dff5a40a88c8d…
PHPDom
I just added a code block as a comment with a sample $embed_html on the gist. Mucho gracias
got some example HTML I can use to test?
I would use a regex.
that’s where I am at now, but failing at target the last item. gist.github.com/2dff5a40a88c8d…