I have the following HTML.
<div class="red">Div One</div>
<div class="green">Div Two</div>
<div class="blue">Div Three</div>
What’s the best way of replacing the text in the div with the green class?
Also, I need a way of retrieving the contents of a tag by element name (), or element name and class ().
Thanks for your help!
You can use some kind of HTML parser. I’d use DOMDocument or phpQuery.
In the edge case, you can use regex. But I do not recommend this to you!
if you want to use class green optional, use