I consider myself pretty proficient in PHP I have written a number of high quality database driven websites in PHP but I am having trouble with what I am trying to do now.
I have a variable filled with HTML data that will look something like this
Blah blah blah
<h1>Whubba</h1>
<h2>ROFL</h2>
This is a test
<h2>OMG</h2>
Yep, it's a test
<h1>LOLZ</h1>
No! It's not!
but there is no particular order, LOLZ could be before Whubba and OMG could be before ROFL. In some cases LOLZ, OMG, or ROFL may not even be there.
Only a few things are certain, the level 1 header Whubba will always be there. If ROFL and OMG are present they will always be after Whubba but before any other level 1 headings that follow Whubba and they will always be level 2 headings.
So I need to extract the content of ROFL and OMG up until the next heading (it could be another h2 or a h1) and save that information in a variable, one for ROFL and one for OMG.
How would I do this?